my ($file, $sfile) = @_; my $csv = Text::CSV->new({binary => 1, decode_utf8 => 1, auto_diag => 1, allow_loose_quotes => 1}); open(my $data, '<:encoding(utf8)', $file) or die "Could not open '$file' $!\n"; my $i = 0; my $ref; my $lineCt = 1; my @header; while(my $line = <$data>){ chomp $line; if($lineCt == 1){ @header = $csv->fields(); $lineCt++; next; } if($csv->parse($line)){ my @fields = $csv->fields(); $ref->[$i] = \@fields; $i = $i+1; } else{ warn "Line could not be parsed: $!",$csv->error_diag; } }