Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Massive expansion of a hash of arrays?

by Sjakie (Initiate)
on Jul 18, 2014 at 19:50 UTC ( [id://1094260]=note: print w/replies, xml ) Need Help??


in reply to Massive expansion of a hash of arrays?

Hi - below similar approach used by yourself... key difference is that it handles the different 'levels' in which data is structured; ie. 'ID' (hash) - 'key1/key2' (hash-of-hash) - 'keyX-valY' (hash-of-hash-of-array).
my %hash=('ID' => { 'key1' => [ "key1_val1", "key1_val2" ], 'key2' => [ "key2_val1", "key2_val2" ] } ); foreach my $id (keys %hash ) { foreach my $keyno ( sort keys %{$hash{$id}} ) { for (my $keyvalno = 0; $keyvalno <= $#{$hash{$id}{$keyno}}; $k +eyvalno++) { print "$id - $keyno - $hash{$id}{$keyno}[$keyvalno]\n"; } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1094260]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 19:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found