in reply to Can Text::CSV_XS return key-value pairs?
#!/usr/bin/perl use warnings; use strict; use Text::CSV_XS qw(csv); use Data::Dumper; my $file = shift; my $csv = 'Text::CSV_XS'->new({ sep_char => '|', quote_char => undef, empty_is_undef => 1, allow_whitespace => 1, }) or die 'Text::CSV_XS'->error_diag; open my $CSV, '<', $file or die $!; my %structure; my $inner = 'Text::CSV_XS'->new({ sep_char => ';', quote_char => undef, allow_whitespace => 1, }) or die 'Text::CSV_XS'->error_diag; while (my $row = $csv->getline($CSV)) { $inner->parse($row->[1]); $structure{ $row->[0] } = [ $inner->fields ]; } print Dumper(\%structure);
Update: Fixed along the suggestions by Tux below.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can Text::CSV_XS return key-value pairs?
by Tux (Canon) on Jun 11, 2017 at 12:45 UTC | |
|
Re^2: Can Text::CSV_XS return key-value pairs?
by Lady_Aleena (Priest) on Jun 13, 2017 at 14:05 UTC | |
by choroba (Cardinal) on Jun 13, 2017 at 23:19 UTC |