c:\@Work\Perl\monks\Fshah>perl -wMstrict -le "use Text::CSV_XS; use Data::Dump qw(dd); ;; my $first_record = '1668;1733;60;32;3173;0;2517;58221;55764;0;0;0;0;Td;30720;1;9;25;0;2; Carry 0'; my $second_record = '1671;1661;0;0;;;0;0;0;0;;;;;;1;9;25;0;2; Carry 1'; ;; my $csv = Text::CSV_XS->new({ sep_char => ';' }) or die 'Text::CSV_XS->new{}: ', Text::CSV->error_diag(); ;; $csv->parse($first_record) or die '1st parse failed'; my @first_fields = $csv->fields; dd \@first_fields; ;; $csv->parse($second_record) or die '2nd parse failed'; my @second_fields = $csv->fields; dd \@second_fields; ;; die 'number of fields differ' unless @first_fields == @second_fields; ;; @second_fields = map { length($second_fields[$_]) != 0 ? $second_fields[$_] : $first_fields [$_] } 0 .. $#first_fields ; dd \@second_fields; " [ 1668, 1733, 60, 32, 3173, 0, 2517, 58221, 55764, 0, 0, 0, 0, "Td", 30720, 1, 9, 25, 0, 2, " Carry 0", ] [ 1671, 1661, 0, 0, "", "", 0, 0, 0, 0, "", "", "", "", "", 1, 9, 25, 0, 2, " Carry 1", ] [ 1671, 1661, 0, 0, 3173, 0, 0, 0, 0, 0, 0, 0, 0, "Td", 30720, 1, 9, 25, 0, 2, " Carry 1", ]