Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I can't find anywhere that tells me how to print the key-value pairs of a hash with multiple values per key. Could someone please help?
This is my attempt below, it prints the keys fine but the values as array references - ARRAY(0x922dc34).
my %hash = map { ($a_v_d_D[$_] => [$isect2[$_], $a_v_b_B[$_], $a_v_c_C +[$_]]) } 0..$#a_v_d_D; while (my ($key, $value) = each (%hash)) { for (my $i=0; $i<@CD_new_a_v_d_D; $i++) { if ($key eq $CD_new_a_v_d_D[$i]) { print "$key - $value\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing hashes with multiple values
by Corion (Patriarch) on Oct 20, 2005 at 09:14 UTC | |
|
Re: printing hashes with multiple values
by blazar (Canon) on Oct 20, 2005 at 10:27 UTC | |
|
Re: printing hashes with multiple values
by revdiablo (Prior) on Oct 20, 2005 at 15:00 UTC | |
|
Re: printing hashes with multiple values
by zentara (Cardinal) on Oct 20, 2005 at 16:02 UTC |