How about something like:
my $file_name = ...; my $file; { open(my $fh, '<', $file_name) or die("Unable to open input file: $!\n"); local $/; $file = <$fh>; } my ($P) = $file =~ /A(.*?)B/ or die("Unable to find 'P'\n"); $file =~ s/(C.*?)\Q$P\E/$1Q/g; { open(my $fh, '>', $file_name) or die("Unable to open output file: $!\n"); print $fh $file; }
Update: Added \Q...\E.
In reply to Re: Second Time Replace Regex
by ikegami
in thread Second Time Replace Regex
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |