Perl Christmas Quiz 2009

Randal L. Schwartz merlyn at
Tue Dec 1 17:06:01 GMT 2009

>>>>> "Dermot" == Dermot  <paikkos at> writes:

Dermot> My first impression was that it would be 4. However, without running
Dermot> it, I would say 0 on the basis that $b is scoped within the loop and
Dermot> (not sure about this point) is a copy of the value in $a{1}.

That's the nice thing about foreach.  The loop variable is aliasing,
not copying, so if there are lvalues in the list, they retain their

 $_ *= 3 for @somelist;

multiplies each element by 3, for example.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at> <URL:>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See for Smalltalk and Seaside discussion

More information about the mailing list