Perl Christmas Quiz

Nicholas Clark nick at ccl4.org
Fri Dec 12 22:13:51 GMT 2008


On Fri, Dec 12, 2008 at 11:01:08PM +0100, Philip Newton wrote:
> On Fri, Dec 12, 2008 at 15:41, Nicholas Clark <nick at ccl4.org> wrote:
> > 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.
> 
> What are they then?
> 
> I can only think of two off the top of my head - things before 'fat
> comma' and the single-word contents of a hash subscript. Hm, do
> filehandles count in things such as "print LOGFILE 'bla'"?

Ah yes. Hash subscripts. That was the one I had forgotten.

1: Predeclared functions
2: File handles
3: Formats
4: Hash subscripts in {}
5: To the left of =>

6: hashes without %

$ perl -wle '%a = ( pie => "mince" ); print keys a'
Unquoted string "a" may clash with future reserved word at -e line 1.
Hash %a missing the % in argument 1 of keys() at -e line 1.
pie

7: arrays without @

$ perl -wle 'push pie, 3.14; print foreach @pie'
Unquoted string "pie" may clash with future reserved word at -e line 1.
Array @pie missing the @ in argument 1 of push() at -e line 1.
3.14


Although, arguably it's 8, if you consider directory handles to be distinct
from file handles. And at this rate I've still missed something.

Summon Dr Evil(tm) to explain all.

Hmm. He's from the future. Surely he should reply to my message before I've
even written it?

Nicholas Clark


More information about the london.pm mailing list