$output_line = substr( $line, 0, 98 ) . $juris1 . substr( $line, 100, 48 ) . $juris2 . substr( $line, 149, 61 ) . "\n";
can be made a bit more readable:
$output_line = "$line\n"; substr($output_line, 99, 1) = $juris1; substr($output_line, 148, 1) = $juris2;
or
$output_line = "$line\n"; substr($output_line, 99, 1, $juris1); substr($output_line, 148, 1, $juris2);
Otherwise, it looks like the only problem you have is that you're not printing out the lines starting with "2", and you end the loop prematurly using last.
while (<INFILE>) { my $line = $_; if ( $line !~ m/^2/ ) { substr($line, 99, 1, "9"); substr($line, 148, 1, "Z"); } print OUTPUT $line; }
Are you having any other problems?
In reply to Re: Replacing Text At Specific Positions
by ikegami
in thread Replacing Text At Specific Positions
by sheasbys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |