NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:
That's very easy in Perl. The most obvious approach is to do a text substitution with a regexp in a loop.
Here's more info on loops and regexps. You might want to check out the monastery's whole Getting Started with Perl node.