Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Answer: How do I make a hash of arrays?

by Doraemon (Beadle)
on May 11, 2004 at 12:38 UTC( #352421=categorized answer: print w/replies, xml ) Need Help??

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

my $array = []; #create new anonymous array ref push (@$array, '11'); push (@$array, '12'); push (@$array, '13'); $hash{'first'} = $array; # add $array = []; #create a new anon-array push (@$array, '21'); push (@$array, '22'); push (@$array, '23'); $hash{'second'} = $array; # add print "Hash content\n"; foreach $k (keys %hash) { foreach (@{$hash{$k}}) { print " : $_"; } print "\n"; }

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 scrutinizing the Monastery: (5)
As of 2016-08-30 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (411 votes). Check out past polls.