trey5498 has asked for the wisdom of the Perl Monks concerning the following question:
I am currently trying to learn Perl (never done until now) and I wrote a small peice of code that I want to read in from an CSV file and place it into an array. At this time I want to print each line of the array so that I know that I am doing it right. Later I will putting it into an output.csv with some changes made.
Here is the code which doesnt seem to working right. PLEASE HELP!!!!!!!!!!!!
Code
use Text::CSV; my @printerstat; $file = 'inputdata.csv'; my $csv = Text::CSV->new(); open (FILE, $file) or die "Couldn't open location file: $!"; while (<FILE>) { $csv->parse($_); push(@printerstat, [$csv->fields]); print @printerstat; } close FILE;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need help with arrays and CSVs
by ww (Archbishop) on Dec 26, 2007 at 20:35 UTC | |
by ww (Archbishop) on Dec 26, 2007 at 21:02 UTC | |
Re: Need help with arrays and CSVs
by jZed (Prior) on Dec 26, 2007 at 20:33 UTC | |
Re: Need help with arrays and CSVs
by derby (Abbot) on Dec 26, 2007 at 20:13 UTC | |
Re: Need help with arrays and CSVs
by NetWallah (Canon) on Dec 26, 2007 at 20:27 UTC | |
Re: Need help with arrays and CSVs
by jrsimmon (Hermit) on Dec 26, 2007 at 21:00 UTC |
Back to
Seekers of Perl Wisdom