in reply to converting Time::HiRes
use Time::HiRes qw(gettimeofday); my $sec = gettimeofday(); # scalar context my ( $s, $ms ) = gettimeofday(); # list context my $float_t = "$s.$ms"; printf "Seconds since epoch (scalar): %d\n", $sec; printf "Seconds since epoch (list): %d.%d\n", $s, $ms; printf "Seconds since epoch (float): %.6f\n", $float_t; printf "Scalar: %s\nList: %s\nFloat: %s\n", scalar(localtime($sec)), scalar(localtime("$s.$ms")), scalar(localtime($float_t)); __DATA__ Seconds since epoch (scalar): 1095126990 Seconds since epoch (list): 1095126990.878512 Seconds since epoch (float): 1095126990.878512 Scalar: Tue Sep 14 11:56:30 2004 List: Tue Sep 14 11:56:30 2004 Float: Tue Sep 14 11:56:30 2004
cheers
tachyon
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: converting Time::HiRes
by Lhamo Latso (Scribe) on Sep 14, 2004 at 06:20 UTC | |
by tachyon (Chancellor) on Sep 14, 2004 at 07:23 UTC | |
by tachyon (Chancellor) on Sep 14, 2004 at 06:58 UTC | |
Re^2: converting Time::HiRes
by poulhs (Beadle) on Oct 04, 2012 at 14:30 UTC |
In Section
Seekers of Perl Wisdom