Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: duplicate keys on hash

by Happy-the-monk (Canon)
on Feb 11, 2015 at 13:21 UTC ( #1116329=note: print w/replies, xml ) Need Help??

in reply to Re: duplicate keys on hash
in thread duplicate keys on hash

While replying to above Anonymonk I am actually clarifying to OP

But I don't see how(in example) typing in the "2" would pull up both BBB AND EEE

The possibly missing information is the syntax used above to treat the hash value - spelled out $hash{$key} - as if it were a plain array is to put it inside this thingy @{ ... } instead of the dots.

You have been shown that it gets into the hash value with the simple push function.

Getting stuff out works the same way:

foreach my $key ( keys %hash ) { foreach my $value ( @{ $hash{$key} } ) { print $key, ": ",$value, "\n" # or whatever you want to do. } }

Cheers, Sören

Créateur des bugs mobiles - let loose once, run everywhere.
(hooked on the Perl Programming language)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1116329]
[choroba]: I only applied for 20 minutes this time
[choroba]: I hope it still means I don't have to pay the conference fee
[LanX]: true it's the built up which is stressy
[choroba]: I doubt I can alter my accent beyond Amercian versus British
[marto]: you mean Scottish :P
[LanX]: your Czech accent is pretty good
[LanX]: oh you think no conference fees for Connery impersonators?
[choroba]: marto that's what I'm not sure about. I've seen Trainspotting a few times, but that's about it.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-04-23 09:35 GMT
Find Nodes?
    Voting Booth?