in reply to Re^4: substitution in regular experssion
in thread substitution in regular expression

Okay, that's a legitimate reason, although it's considered polite to let people know that you're asking for assignment help in the original post.

AnomalousMonk has shown a way to do it in one line, although that solution doesn't modify the string.

If you want to evaluate code on the right-hand side of your search/replace regular expression, see the /e modifier in perlop.

  • Comment on Re^5: substitution in regular experssion