in reply to Re: How to replace empty values with value in previous array
in thread How to replace empty values with value in previous array

Thanks for the reply, I have an array with 100's of these lines how can I perform the same operation over entire array line by line

  • Comment on Re^2: How to replace empty values with value in previous array

Replies are listed 'Best First'.
Re^3: How to replace empty values with value in previous array
by poj (Abbot) on Jul 20, 2017 at 09:07 UTC

    Do you want to create a new array or overwrite the existing ?

      I want to overwrite the array(considering It might be faster)
        #!perl use strict; my @prev = (); my @lines = <DATA>; chomp(@lines); for (@lines){ my @row = split ';',$_; for my $i (0..$#row){ if ( length ($row[$i]) == 0 ){ $row[$i] = $prev[$i]; } } $_ = join ';',@row; @prev = @row; } print "$_\n" for @lines; __DATA__ 1668;1733;60;32;3173;0;2517;58221;55764;0;0;0;0;Td;30720;1;9;25;0;2; C +arry 0; 1671;1661;0;0;;;0;0;0;0;;;;;;1;9;25;0;2; Carry 1;