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;
}
}
Shamelessly stole Corion's printf() since it was better.