in reply to merge code

As already hinted by BrowserUk it's not easy to put the exact same semantics into a single statement.

The three substitutions replace the first occurrence of each of the patterns. I don't even know if that's possible in a regex.

Consider the case that input data is %EX% %EC% %EX% %BC% - the original code prodcues TOdelete TOdelete %EX% TOdelete for that.

If you really need that behaviour, you can use this:

while(<DATA>){ my %seen; s/(%(?:EX|BC|EC)%)/$seen{$1}++ ? $1 : "TOdelete" /ge; print $_; }
Perl 6 - links to (nearly) everything that is Perl 6.