package Watch; use strict; sub new { my ($class) = @_; my $self = { }; bless $self, $class; $self->set_time("0:0:0"); return $self; } sub set_time { my ($self,$time) = @_; my ($hrs,$mins,$secs) = split /:/, $time; my $seconds_from_zero = ($hrs*60 + $mins) * 60 + $secs; my $now = time; $self->{'ticker'} = $now - $seconds_from_zero; return $self; # XXX } sub time { my ($self) = @_; my $now = time; my $seconds_from_zero = $now - $self->{'ticker'}; my $secs = $seconds_from_zero % 60; $seconds_from_zero /= 60; my $mins = $seconds_from_zero % 60; $seconds_from_zero /= 60; my $hrs = int($seconds_from_zero); return "$hrs:$mins:$secs"; } 1;