in reply to Re: Need help with arrays and CSVs
in thread Need help with arrays and CSVs
...and if your data is multiline, eg:
this is a field to start with,field2,field3 #,*,field3 of line 2 field1 of line3,and this is the second field of line3,field3 of line3
then replacing the relevant part of the above code with this fragment produces a line of output for each field:
while (<FILE>) { $csv->parse($_); push(@printerstat, $csv->fields); # print @printerstat; } spit(@printerstat); sub spit { for my $field(@printerstat) { print "$field\n"; } }
thusly
this is a field to start with field2 field3 # * field3 of line 2 field1 of line3 and this is the second field of line3 field3 of line3
This also works if some of your fields are void, eg:
,,this is a row with two empty fields
|
---|
In Section
Seekers of Perl Wisdom