http://www.perlmonks.org?node_id=1055709


in reply to Reading File and Seperating into columns

Your friend is horribly misinformed. Without handling any special CSV rules, a simple conversion from pipe to comma looks like this:

my @inpelt = split /\|/, $inpbuf; my $outbuf = join ',', @inpelt;

or this

$trnbuf =~ s/\|/,/g;

That said, if Text::CSV has grown up enough to be fully functional (and I suspect it has), you are very, very well advised to use it.

The proposed, and essentially de facto, CSV standard has a fair number of special cases which a proper CPAN module should be handling for you. Rolling your own, such as using the shortcuts shown above, would only work if you were absolutely certain the data crossed none of the CSV special handling cases.

A programmer writes code that works in a year; a software engineer writes code that works in ten years.

Failing to use a fully functional CPAN module to handle the CSV special cases would be a fine example of programming, not engineering, in this context.

Cheers!