Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Answer: How do I make a hash of arrays?

( #6620=categorized answer: print w/ replies, xml ) Need Help??

Q&A > Data Structures > How do I make a hash of arrays? contributed by chromatic

my %dramatis_personae = ( humans => [ 'hamnet', 'shakespeare', 'robyn', ], faeries => [ 'oberon', 'titania', 'puck', ], other => [ 'morpheus, lord of dreams' ], );
Access it like this:
foreach my $group (keys %dramatis_personae) { print "The members of $group are\n"; foreach (@{$dramatis_personae{$group}}) { print "\t$_\n"; } }

Comment on Answer: How do I make a hash of arrays?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-10-23 21:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (129 votes), past polls