SPUG: Perl oddity?
John W. Krahn
krahnj at acm.org
Thu Jan 29 04:19:00 CST 2004
On Wednesday 28 January 2004 21:06, Tim Maher wrote:
> 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.)
You "guess"?! :-) It's easy enough to prove.
$ perl -le' sub context { print wantarray ? "LIST" : "SCALAR", " context" } localtime context'
SCALAR context
John
--
use Perl;
program
fulfillment
More information about the spug-list
mailing list