in reply to replace/substituion 4th field
Considering you have already split up $line, why replace in the original? I would simply join @fields like so:
while (my $line = <$data>) { chomp $line; my @fields = split ",", $line, -1; my $sum = $fields[3]; $fields[3] = 'volemd' if ($fields[3] > 310 ) ; $fields[3] = 'volemd1' if ($fields[3] == 70 ) ; print join( ',', @fields ) . "\n" ; }
Update: Modified as per correction by jwkrahn below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: replace/substituion 4th field
by jwkrahn (Abbot) on Feb 20, 2013 at 17:04 UTC | |
by tmharish (Friar) on Feb 21, 2013 at 06:39 UTC |