in reply to Replacing expression on certain line numbers
Read your index file into a hash:
open my $idx, '<', 'index.file' or die "Can't open 'index.file' for re +ading: $!"; my %index; while (<$idx>){ chomp; $index{$_} = 1; }
And then go through your data file, and replace as needed while copying to a temporary file:
while (<$in>) { if ($index{$.}){ s/foo/bar/g; } print $tmp $_; }
When you're done, override the data file with the temporary file.
|
|---|