use strict; use warnings; use Text::CSV_XS; use File::Copy; my $tr_csv = Text::CSV_XS->new({ binary => 1, eol => $/ }); open my $tmp,'>','tmp.csv' or die "Failure opening temp file: $!"; open my $tr,'<','file.csv' or die "Failure opening data file: $!"; while (<$tr>) { if ($. == 1) { $_ = substr $_,2; } s/\c@//g; print $tmp $_; } close $tmp or die "Failure closing temp file: $!"; close $tr or die "Failure closing data file: $!"; move 'tmp.csv','file.csv'; open $tr,'<','file.csv' or die "Failure opening data file: $!"; while (my $row = <$tr>) { $tr_csv->parse($row); my ($x,$y,$z) = split /,/,$row; print "x: $x\n"; }