Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: How to replace empty values with value in previous array

by poj (Abbot)
on Jul 20, 2017 at 12:23 UTC ( [id://1195602]=note: print w/replies, xml ) Need Help??


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

#!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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195602]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found