Interesting question... I think I can answer it.
Basically, localtime is specially written such that calling it in scalar context (which is what scalar does) will return a string, rather than just a list converted to scalar (e.g. 9). This is done through using wantarray. Take this example:
sub cheese {
my @cheese = qw(cheddar swiss);
if (wantarray) { return @cheese }
else { return $cheese[0] }
}
Basically, wantarray will tell you if your subroutine was called in scalar or list context, as I understand it. It's used here to return at least some kind of cheese, so that if all the caller wants is some cheese, they'll get it.
It should also be noted that you can check to see if the sub was called in void context by using defined wantarray.
BTW, if you really wanted 9, you could try this code:
scalar (@_ = localtime(time))
Update: Or you could do like bwana147 suggested and assign to an empty list, preserving the contents of @_. That'd probably be better.
(I only hope not too many people think I'm obsessed w/ cheese now...)
His Royal Cheeziness |