package Stopwatch; use strict; use warnings; use Moose; use DateTime; has 'timer' => ( is => 'rw', isa => 'DateTime', default => sub { DateTime->now } ); sub diff { my $self = shift; $self->time - DateTime->now; } # ... my $sw = Stopwatch->new; # ... wait a moment print $sw->diff;