http://www.perlmonks.org?node_id=669760


in reply to Hash problem: each() failure

Hi Anonymous Monk.

As Corion mentioned, you used the anonymous hash syntax, i.e., $name_of_hash = { ... };

Assigning a list to a hash variable will result in the key/value pair(s) being created.
use warnings; use strict; my %Cls = qw( P a N b U c ); print %Cls, "\n\n"; while ( my ($k, $v) = each( %Cls ) ) { print "$k => $v\n"; }

Update: Fixed typo by changing %name_of_hash = { ... }; to $name_of_hash = { ... }; after ikegami++ noticed it. Thanks.

Hope this helps,
~Katie