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

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

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

Replies are listed 'Best First'.
Re^4: How to replace empty values with value in previous array
by Fshah (Initiate) on Jul 20, 2017 at 09:17 UTC
    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;