Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
No such thing as a small change
 
PerlMonks  

Re: generating hash from array

by chester (Hermit)
on Oct 21, 2005 at 15:27 UTC ( #502045=note: print w/ replies, xml ) Need Help??


in reply to generating hash from array

This relies a lot on auto-vivification:

use warnings; use strict; use Data::Dumper; my %hoh; while(<DATA>) { chomp( my @fields = split /-/, $_ ); push @{ $hoh{$fields[0]}->{$fields[1]} }, $fields[2] } print Dumper \%hoh; __DATA__ comp1-cmd1-test1 comp1-cmd1-test2 comp1-cmd2-test1 comp2-cmd1-test1 comp2-cmd1-test2 comp3-cmd1-test1

Update: added chomp


Comment on Re: generating hash from array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-04-18 09:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (465 votes), past polls