http://qs321.pair.com?node_id=494889


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
# 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)); }
poj