Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Efficient solution needed for this program

by Limbic~Region (Chancellor)
on Apr 03, 2007 at 13:36 UTC ( [id://608061]=note: print w/replies, xml ) Need Help??


in reply to Efficient solution needed for this program

valavanp,
What do you mean it isn't efficient? Perhaps you should look up the definition of the word. I will go out on a limb and guess that you want it to run faster. In any case, converting the CSV was not necessary.
$!/usr/bin/perl use strict; use warnings; use Text::CSV_XS; my $file = $ARGV[0] or die "Usage: $0 <input_file>"; open(my $fh, '<', $file) or die "Unable to open '$file' for reading: $ +!"; my $csv = Text::CSV_XS->new; while (<$fh>) { chomp; if ($csv->parse($_)) { printf "'%s'\t'=>\t'%s'\n", $csv->fields; } else { print STDERR "parse() failed for '$_': ", $csv->error_input; exit; } }

Cheers - L~R

Shamelessly stole Corion's printf() since it was better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://608061]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found