Perl Christmas Quiz 2009
Randal L. Schwartz
merlyn at stonehenge.com
Mon Nov 30 20:14:21 GMT 2009
>>>>> "Dave" == Dave Cross <dave at dave.org.uk> writes:
>> 1) Without running it to check, what does the following program output?
>>
>>
>> my %a = (3,2,1,0);
>>
>>
>> for my $b (sort values %a) {
>> $b += 4;
>> }
>>
>>
>> print $a{1} . "\n";
Dave> Without running it, I'd say 4. Having now run it, I'm glad that's what I said
Dave> :)
When did "sort" start returning lvalues? I bet if you did this
on an older Perl, it'd return 0.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
More information about the london.pm
mailing list