![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
The second one should be written with curly brackets not parenthesis.
Otherwise you are trying to assign a list to a scalar. use warnings would have told you this:
This is referring to the members of the list that were discarded when it was assigned to a scalar. Everything but the last 3 was discarded. Further use strict would have told you:
$test holds the number 3. When you try to dereference the number 3 (a la %{$test} it converts it to a string "3" and then looks up the hash called "%3" in the symbol table. strict doesn't allow such shenanigans. The curly brackets in the correct example indicate an anonymous hash reference. References are scalars. So it assigns to $test just fine. Don't study too hard though - the confusion between references-to-objects and the objects themselves will be going away in Perl 6. (or getting worse, depending how you look at it, :) ) -Andrew. In reply to Re: Counting keys in a referenced hash
by tomazos
|
|