SPUG: Perl oddity?

Tim Maher tim at consultix-inc.com
Wed Jan 28 23:06:21 CST 2004


On Wed, Jan 28, 2004 at 08:54:49PM -0800, Marc M. Adkins wrote:
> # I was a little surprised at this...
> 
> print join('/', reverse localtime), "\n";
> print join('/', reverse localtime(time)), "\n";
> 
> @t = ( time );
> 
> print join('/', reverse localtime($t[0])), "\n";
> print join('/', reverse localtime(@t)), "\n";	# ????????
> print join('/', reverse localtime(shift(@t))), "\n";
> 
> # I would have thought that the line with the question
> # marks would have worked the same as the rest.
> # mma

My guess is that localtime is "prototyped" as receiving a
scalar value, so in that ??? statement you're actually
passing the number of items in the array, which is 1, rather
than the epoch-seconds value (I'll leave the testing of that
hypothesis to you.)


*--------------------------------------------------------------------------*
| Tim Maher, CEO     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
|  Watch for my Manning book: "Minimal Perl for Shell Users & Programmers" |
*--------------------------------------------------------------------------*



More information about the spug-list mailing list