package Timer;
sub new
{
my $self=shift;
$dd={};
$dd{"created"}=time;
print "the time now is $dd{'created'}"."\n";
bless $dd,$self;
}
sub diff
{
my $self=shift;
my $ff= time - $self->{created};
}
package main;
$timer=new Timer;
sleep 4;
$dd=$timer->diff;
print "time elapsed is $dd"
Output:
G:\perl_programs>perl perl_object1.pl
the time now is 1310282015
time elapsed is 1310282019
G:\perl_programs>
No comments:
Post a Comment