It seems like you're trying to operate on 2-row blocks? Like if the first row meets some match criteria, then meld it into the next row?
...then maybe break up the file into 2-row blocks and use regexes on each one.. Like split it this way:
my @tworows = split /[^\n]+\n[^[n]+\n/, $text;
then you can just use something like
s/((\w+).+\1.+\1.+)\n(.+)/something/
then repeat that starting on the first even row (because the regex always checks the FIRST row for matches). Much simpler than storing all those temporary arrays, whiles, ifs, etc.
But here are few recomendations:
1. next; } is the same as } 2. Don't make a copy of your row array to use it, just dereference it: my @row1 = @{$row}; # not needed.. Just use $row->[$index] instead of $row1[$index] 3. drop all the extra parens join ';', @arr; push @arr, 'something'; 4. it looks like you're using a numeric == to compare ascii fields lik +e $row1[0] == $row2[0] when col 0 contains things like 'PF'. Use eq f +or these compares. You can't use == there.
In reply to Re: perl: How to comapre and manipulate csv file in perl?
by misterperl
in thread perl: How to comapre and manipulate csv file in perl?
by Ankur_kuls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |