#!/perl/bin/perl use strict; use warnings; use Text::CSV_XS; my $csv = Text::CSV_XS->new( { binary => 1 } ); my $infile = "foo.txt"; open(IFH, "<", $infile) or die "Could not open infile for reading.\n"; while(my $line = ) [ my $success = $csv->parse($line); if ($success) { ... stuff it in your hash ... } else { ... complain about it ... } } close IFH;