You are constructing an array with three elements, getting a reference to it and passing it to localtime. localtime treats the reference as a number, resulting in the address, and uses the address as the number of seconds since epoch.
use POSIX qw( strftime ); my $ref = [ 0 .. 2 ]; print($ref, "\n"); printf("%X\n", 0+$ref); print(strftime('%Y-%m-%d %H:%M:%S', localtime($ref)), "\n"); print(strftime('%Y-%m-%d %H:%M:%S', localtime(0+$ref)), "\n");
ARRAY(0x225248) 225248 1970-01-26 19:48:08 1970-01-26 19:48:08
The parentheses are necessary to remove the ambiguity (by requiring an operator instead of an expression).
perl -MO=Deparse and perl -MO=Deparse,-p help with parsing problems.
Update: Corrected spelling mistake pointed by jwkrahn.
In reply to Re: (localtime) versus localtime - round 1
by ikegami
in thread [Updated] (localtime) versus localtime - round 1
by Lawliet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |