Do not use parse (it'll break your script on fields with newlines). Use getline instead!
Ah, good point. Funny, my first iteration of the script actually used ->getline(), but then I reckoned that in $csv->getline(*DATA) couldn't be generalized so easily to the magic filehandle. I didn't want to sacrifice the convenience of not having to explicitely open files; the issue with newlines didn't occur to me, but you're right. The devil is in the details...
Looking at perlop now, it also turns out that <> is actually just a shorthand for <ARGV> (which is just as magic): you can write $csv->getline(*ARGV) and still have everything Just Work™, both piping data into the script and supplying a filename (or several) on the command line.
Thanks for enlightening me, brother!
In reply to Re^3: Find the row with shortest string for a given input in a csv file.
by AppleFritter
in thread Find the row with shortest string for a given input in a csv file.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |