in reply to Re: Re: Current time as variable?
in thread Current time as variable?

That is because in sub stoptime, your script doesn't know what $start is, since you only declared that in the starttime sub. Now if you'd do it like the following, it would print out 5:
my $start; my $end; &starttime; &stoptime; sub starttime{ $start = time; sleep 5; } sub stoptime{ $end = time; print $end - $start."\n"; }

Update: If you'd put "use strict;" in the beginning of your little snippet, Perl would warn you about this with: Global symbol "$start" requires explicit package name at test line 14.

--
b10m