use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1, sep_char => "\t", auto_diag => 1 }); my @headers = $csv->header ($in); # Read the docs, there are options possible here while (my $row = $csv->getline ($in)) { # ... }