in reply to Re^2: ideas on how to improve existing code
in thread ideas on how to improve existing code
It was nothing personal, but I am on a crusade in trying to prevent people that already use Text::CSV, Text::CSV_XS and/or Text::CSV_PP to use
while (<$fh>) { my @row = $csv->parse ($_); ...
which I was referring to with your "perl parsing method" (or any variation thereof) instead of
while (my $row = $csv->getline ($fh) { ...
Which is not only faster, but immensely safer. Under the hood both <> and $csv->getline use perl's getline function and both respect the (perlio) layers, but the upper method is not able to detect the difference between an embedded $/ inside quotes or at the end of a line, so it is very open to erroneous behavior. Besides that, CSV's getline is more lenient towards trailing carriage returns and/or newlines (unless you explicitely set the eol attribute.
|
|---|