http://www.perlmonks.org?node_id=11132571


in reply to Need to get hash of arrays

As you are collecting solutions.. and dealing with highly malformed data..

perl -MData::Dump -F"\|\s?" -lane "$.==1?next:push@{$h{eval$F[0]=~tr/\ +s//r}},$F[1]}{dd%h" columndata.txt ( 500002, ["Network2"], 500003, ["Network1", "Network3"], 500001, ["Network1", "Network2"], )

which deparsed gives:

perl -MO=Deparse -MData::Dump -F"\|\s?" -lane "$.==1?next:push@{$h{eva +l$F[0]=~tr/\s//r}},$F[1]}{dd%h" columndata.txt BEGIN { $/ = "\n"; $\ = "\n"; } use Data::Dump; LINE: while (defined($_ = readline ARGV)) { chomp $_; our @F = split(/\|\s?/, $_, 0); $. == 1 ? next : push(@{$h{eval $F[0] =~ tr/s//r};}, $F[1]); } { dd(%h); } -e syntax OK

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.