Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to loop through it likeuse constant GROUPS => { A => 1, B => 2, C => 3 }; use constant A => { 1 => x, 2 => y, 3 => z }; use constant B => { 1 => x, 2 => y, 3 => z };
here is the problem I need to loop through the $k which is a constant hash, I would like to know how I can represent $k hash in the below each() ,so that it represents constants hashes A,B, etcwhile ( my ($k,$val) = each %{ +GROUPS } ) {
Thanks,while ( my ($k,$val) = each ($k)) { print $k{val} ; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash and constants
by ikegami (Patriarch) on Nov 19, 2009 at 23:17 UTC | |
|
Re: hash and constants
by zwon (Abbot) on Nov 19, 2009 at 23:15 UTC | |
by Anonymous Monk on Nov 19, 2009 at 23:30 UTC |