XP is just a number | |
PerlMonks |
Re: Cool way to parse Space Separated Value and CSV filesby johngg (Canon) |
on Apr 12, 2013 at 22:53 UTC ( [id://1028463]=note: print w/replies, xml ) | Need Help?? |
Since you state that the first line in the file is important it might be as well to treat it differently by assigning it to a separate scalar variable. Also, when you split the header to get the column names you could save having to do the shift by assigning the first value to undef which can act as a sort of programmatic bit bucket.
The output.
The technique falls to pieces somewhat when your space-separated files contain fields or headers containing spaces, or a CSV file with commas dotted around. You would then reach for something like Text::CSV. I hope this is of interest. Cheers, JohnGG
In Section
Cool Uses for Perl
|
|