in reply to Time Difference

FWIW, this works with time(), but not localtime().

(With localtime, you get an "argument isn't numeric in subtraction" error.)

#filename: stickOutputOnEnd.pl use warnings; use strict; my $time1 = time(); sleep(5); my $time2 = time(); my $timedifference = $time2-$time1; # doesn't work if you use localtim +e. print scalar $timedifference;

Replies are listed 'Best First'.
Re^2: Time Difference
by gellyfish (Monsignor) on Mar 18, 2005 at 10:01 UTC

    FWIW, this works with time(), but not localtime().

    Er, yes. Because they have two quite distinct functions. time() returns the epoch seconds representing the current time and localtime() (or gmtime()) returns a list representing the parts of the time (like the struct tm returned by the similarly named C library functions.) when in list context or a string represention thereof when in scalar context.

    /J\

      Thank you all. That really helps.