in reply to Re^2: Parsing and modifying CSV files
in thread Parsing and modifying CSV files
Another way would be to use the conditional operator inside a loop
poj# field number for sizes SM MD LG XL my @fno =(9,12,15,18); while (<DATA>) { ## file2 my @data = split(',',$_); my $ky = $data[0]; if (exists $stock{$ky}) { # check each size for my $sz (0..3){ $data[$fno[$sz]] = ( $stock{$ky}[$sz] eq '0' ) ? '' : '0' ; } } print (join(',', @data)); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Parsing and modifying CSV files
by poj (Abbot) on Sep 26, 2005 at 21:18 UTC | |
Re^4: Parsing and modifying CSV files
by Anonymous Monk on Sep 26, 2005 at 20:49 UTC |
In Section
Seekers of Perl Wisdom