for (1..6){ $line = <$input_file>; print $output_file $line; } #### my $M = 5; # constant multiplier my $T = 0.1 # negative number threshold my $al = 0; # alternator while(<$input_file>){ s|([-.\d]+)| if($1 == -9999){ $1; # leave -9999 alone } elsif( $1 < 0 and abs($1) < $T ){ $al++ % 2 ? 0 : -9999; # replace small negative with 0 or -9999 } else { $1 * $M; # multiply other numbers by constant } |ge; print $output_file; }