Phoenix.pm: quiz

Beaves at aol.com Beaves at aol.com
Wed Dec 15 23:47:19 CST 1999


This little bit of code gave me the RCA dog look for a while.  After thinking 
it through, it made sense.

If references are not your strong suit, then read on.
What will the final print statement say for each of these snippets?

$hash = {1=>one, 2=>two, 3=>three};
$list = [fred, barney, $hash, wilma];
$hash = {1=>ONESIE,2=>TWOSIE,3=>THREESIE};
print STDOUT "value is:'$$list[2]{2}' "   # is it 'two' or 'TWOSIE'

$hash = {1=>one, 2=>two, 3=>three};
$list = [fred, barney, $hash, wilma];
$$hash{2} = TWOSIE;
print STDOUT "value is:'$$list[2]{2}' "   # is it 'two' or 'TWOSIE'

__END__

So what is it?

Just another of my little Perl pseudo-gotchas...

Tim




More information about the Phoenix-pm mailing list