What Discipulus said:
You really should know all this by now. (sigh)Win8 Strawberry 5.8.9.5 (32) Fri 05/14/2021 4:48:55 C:\@Work\Perl\monks\workInProgress12 >perl use strict; use warnings; use autodie; use Data::Dump qw(dd); my $data = <<'EOD'; ColA | ColB | 500001| Network1| 500003| Network1| 500002| Network2| 500001| Network2| 500003| Network3| EOD open my $fh, '<', \$data; <$fh>; # ignore headings record/line my %hash4; while (<$fh>) { my ($k, $v) = map { (my $r = $_) =~ s{ \A \s+ | \s+ \z }{}xmsg; $r; } split /\s*\|\s*/ #splits $_ implicitly ; # print "\$k '$k' \$v '$v' \n"; # for debug push @{ $hash4{$k} }, $v; } dd \%hash4; close $fh; ^Z { 500001 => ["Network1", "Network2"], 500002 => ["Network2"], 500003 => ["Network1", "Network3"], }
Give a man a fish: <%-{-{-{-<
In reply to Re: Need to get hash of arrays
by AnomalousMonk
in thread Need to get hash of arrays
by chandantul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |