Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2015-07-04 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls