Perl Christmas Quiz

Nicholas Clark nick at ccl4.org
Fri Dec 12 14:41:07 GMT 2008


On Fri, Dec 12, 2008 at 11:37:23AM +0000, Joel Bernstein wrote:

> > 4) How many different variable types are there in Perl? Be as sensibly voluminous in your answer as you are able.
> 
> SCALAR ARRAY HASH CODE
> FileHandle DirHandle Regexp
> 
> But clearly we distinguish between numeric and string scalar values,
> so I'm wondering how exhaustive that list is...

Unless I'm misremembering, there are 7 namespaces

SCALAR
ARRAY
HASH
CODE
file handles
directory handles
FORMAT

> > 7) What does the L in Randal L Schwartz stand for?
> 
> Loser.

That's not nice and we play nice here.


On Sat, Dec 13, 2008 at 01:17:33AM +1100, Paul Fenwick wrote:

> > 4) How many different variable types are there in Perl? Be as sensibly
> > voluminous in your answer as you are able.
> 
> Hashes.
> 
> Arrays.
> 
> Scalars:
> 	* Integers
> 	* Floats
> 	* Strings
> 	* Many of the above (eg, $! is a dualvar)
> 	* References
> 	* Regexps
> 	* Code references
> 	* Glob aka filehandle references.
> 	* Real filehandles, kind of
> 	* undef
> 	* Magic variables.

I'm going with the version as above. What you see from Perl space is

SCALAR
ARRAY
HASH
CODE
file handles
directory handles
FORMAT

although the two in lower case are {IO} in a typeglob. Which is a fun thing:

$ perl -le '$a = ${*STDOUT{IO}}'
Bizarre copy of IO in sassign at -e line 1.

regexps internally became a first class concept in 5.11

> > 13) Think of a witty and/or interesting Perl Christmas quiz question and
> > answer it.

I'm going for

What are the 7 classes of unquoted string that are not barewords. I think it's
7. It usually requires a Damian to remember them all. Most I can get.

Nicholas Clark


More information about the london.pm mailing list