in reply to Re: Need to get hash of arrays
in thread Need to get hash of arrays
Or with Text::CSV/Text::CSV_XS:
use warnings; use strict; use Data::Dump; use Text::CSV; # also install Text::CSV_XS for speed my %data; my $csv = Text::CSV->new({ binary=>1, auto_diag=>2, sep_char=>"|", allow_whitespace=>1 }); my $hdr = $csv->getline(*DATA); while ( my $row = $csv->getline(*DATA) ) { push @{ $data{ $row->[0] } }, $row->[1]; } $csv->eof or $csv->error_diag; dd \%data; __DATA__ ColA | ColB | 500001| Network1| 500001| Network2| 500002| Network2| 500003| Network1| 500003| Network3|
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Need to get hash of arrays
by chandantul (Scribe) on May 15, 2021 at 18:40 UTC |
In Section
Seekers of Perl Wisdom