SPUG: Perl oddity?

Colin Meyer cmeyer at helvella.org
Thu Jan 29 12:34:08 CST 2004

On Thu, Jan 29, 2004 at 02:19:00AM -0800, John W. Krahn wrote:
> On Wednesday 28 January 2004 21:06, Tim Maher wrote:


> > 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

Or you can use:

  perl -le'print prototype "CORE::localtime"'

So, it optionally takes one scalar argument. Lots on prototypes in
'perldoc perlsub'.

... speaking of which, how many Perl programmers make use of prototypes
on a regular basis? It seems that most of my modules are OO, and method
calls in Perl ignore the prototype, so I end up seldomly using them.


More information about the spug-list mailing list