in reply to Replacing Text At Specific Positions
$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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replacing Text At Specific Positions
by ikegami (Patriarch) on Jun 05, 2007 at 16:01 UTC |