An approach using nested substitutions is also possible, but there may be a bit too much double-negation going on here for comfort.
use warnings;
use strict;
my $text = <<'EOT';
I am IntErEsted in making changes to the following lines.
However, START thE chAnges mUst bE \CME madE hErE. END
There may be cases whErE
START chAngEs nEEd to be mAdE \CME hErE
tOO. END
EOT
$text =~
s{ (?<= START) (.*?) (?= END) }
{ (my $replacement = $1) =~
s{ (?<! \S) ([^\s\\] \S*) }
{ lc $1 }xmsge;
$replacement;
}xmsge;
print qq{[[$text]] \n\n};
[[I am IntErEsted in making changes to the following lines.
However, START the changes must be \CME made here. END
There may be cases whErE
START changes need to be made \CME here
too. END
]]
Good luck with the homework.
|