[oak perl] The mysterious "undef"

Benjamin Elijah Griffin oaklandpm at eli.users.panix.com
Mon Mar 21 14:27:47 PST 2005


Zed Lopez <zed.lopez at gmail.com> wrote:
>>  #$sec, $min,$hour,$mday,$mon,  $year,$wday,$yday,$isdst
>>  (undef,$min,$hour,$day, $month,$year,undef,undef,undef) =
>>  localtime();
> You don't need the ones on the right.

Nope, but along with the comment about what is in what field,
I'd always leave them in for a localtime assignment in real code.

> ($min,$hour,$day, $month,$year) = (localtime)[1..5]

And that's just fine and dandy, a nice example of an array slice,
but not a useful example of undef().

Elijah


More information about the Oakland mailing list