achs has asked for the wisdom of the Perl Monks concerning the following question:
The array in the two cases mentioned is different. I am getting output as below where you can see the keys not as usual. I am not able to access the keys also, basically it is not getting.use strict; use warnings; use diagnostics; use Data::Dumper; my %hash; my $key; my $value; my @data = ("foo",1, "bar",2, "foo",3, "baz",4); while ($key = shift (@data)) { $value = shift (@data); # push the value on the array push @{$hash{$key}}, $value; } print Dumper \%hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple values assigned to same key in hashes
by Random_Walk (Prior) on Feb 11, 2016 at 09:11 UTC | |
|
Re: Multiple values assigned to same key in hashes
by AnomalousMonk (Archbishop) on Feb 11, 2016 at 17:10 UTC | |
|