Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Reading File and Seperating into columns

by marinersk (Priest)
on Sep 25, 2013 at 16:10 UTC ( #1055709=note: print w/replies, xml ) Need Help??

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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055709]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2017-05-28 22:38 GMT
Find Nodes?
    Voting Booth?