February 2012
Intermediate to advanced
1184 pages
37h 17m
English
time
This function returns the number of nonleap seconds since “the
epoch”, traditionally 00:00:00 on January 1, 1970, UTC.[254] The returned value is suitable for feeding to gmtime and localtime, for comparison with file
modification and access times returned by stat, and for feeding to utime.
$start = time();
system("some slow command");
$end = time();
if ($end – $start > 1) {
say "Program started: ", scalar localtime($start);
say "Program ended: ", scalar localtime($end);
}For measuring time in finer granularity than integer seconds, use
the Time::HiRes module, included with Perl since the v5.8 release and
available from CPAN earlier than that.
[254] Not to be confused with the “epic”, which is about the making of Unix. (Other operating systems may have a different epoch, not to mention a different epic.)
Read now
Unlock full access