[Israel.pm] List of all contexts in Perl

Mikhael Goikhman migo at homemail.com
Sun May 30 04:25:21 PDT 2010

On 30 May 2010 10:32:13 +0000, Mikhael Goikhman wrote:
> In fact localtime works differently under scalar, boolean (works like
> numerical here) and list contexts. Run this if you don't believe me:
> 	perl -le 'print scalar localtime'
> 	perl -le 'print int localtime'
> 	perl -le 'print localtime == 0 ? "TRUE" : "FALSE"'
> 	perl -le 'print join ", ", localtime'
> But most of other built-in functions may work the same under numeric,
> scalar, boolean or say dereferencing contexts. This does not mean
> these contexts do not exist. :)

To make it clear. This whole story about localtime being special was
just a funny attempt to demonstrate contexts. It is not true. This
function is not different from most of other functions that work the
same under scalar, numeric and boolean contexts:

	perl -wle 'print localtime() ? "TRUE" : "FALSE"'

But maybe in some future perl version this line will print "FALSE" if
the system time is set to year 1869 or 2040. :)

The rest of the message was serious however and I hope useful.


perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'

More information about the Perl mailing list