use strict; use Text::CSV_XS; my $csv = Text::CSV->new; my $csv_file = 'schedulea.csv'; open CSVFILE, "< $csv_file" or die "Can't open $csv_file for reading: $!"; while () { my $status = $csv->parse($_); if ( $status ) { my @columns = $csv->fields(); # do stuff with columns } else { my $bad_argument = $csv->error_input(); # do stuff with the error } }