my $csv = Text::CSV_XS->new; # Or Text::CSV my @hdr = $csv->header ($if, { detect_bom => 1 }); # No need for $csv->column_names, as that is implicit in ->header