in reply to Find duplicate values in hash
gives you an error because the %{...} in %{$hash{$key}} is attempting to treat the value of $hash{$key} as a hash ref - but it's really a scalar, as you say you want. So replace %{$hash{$key}} with %hash to make it work. I see the other post had a double-nested hash, which is why you would need this particular syntax.for my $key (keys %hash) { my $value_key = "@{[values %{$hash{$key}}]}"; }
It also stores "@{[...]}" in a scalar used as a hash slice - normally you wouldn't need this and could just say values %hash. Hope this helps at all...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find duplicate values in hash
by moff (Novice) on Apr 11, 2009 at 13:25 UTC | |
by moff (Novice) on Apr 17, 2009 at 19:17 UTC |