in reply to Re: Conditional initialisation
in thread Conditional initialisation
Ah, well the last time I used this construct it was for a function that could accept either a unix timestamp as a scalar, or a time vector as returned by localtime() or gmtime().
So I was checking the length of @_ to see if it was greater than 1 (not 0), like this:
sub unix_to_datetime { my @time_vec; @time_vec = @_ if @_>1; unless (@time_vec) { my $time = shift; @time_vec = (defined $time ? localtime($time) : localtime); } return strftime('%Y-%m-%d %H:%M:%S', @time_vec); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Conditional initialisation
by dragonchild (Archbishop) on May 25, 2004 at 02:00 UTC |