in reply to This has me stumped, pattern matching, 2 files
open A, '<', 'fileA' or die "Cannot open 'fileA' $!"; my %lines; while ( <A> ) { $lines{ $. } = () if /X/; } close A; open B, '<', 'fileB' or die "Cannot open 'fileB' $!"; my $count; while ( <B> ) { s/(Y)/ exists $lines{ ++$count } ? 'Z' : $1 /eg; print; # updated to print lines } close B;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: This has me stumped, pattern matching, 2 files
by ikegami (Patriarch) on Nov 21, 2006 at 07:56 UTC |