in reply to regexp and a perl function

If you're just changing one set of characters into another set of characters rather than utilizing the full power of the regular expression engine, you might just want to use the transliteration operator tr///

# turn all of the "a" characters into "r"s and all of the "b"s into "s +"s, etc. $string =~ tr/abcd/rstu/;

See perlop for more info on tr///