my $test = "Wherefore art thou, Ovid, you moronic chowderheaded shell of a ghost? Give me my fleas and leaf."; $test =~ s/\b(qu|[cgpstw]h|[^\W0-9_aeiou])?([a-z]+)/$1?"$2$1ay":"$2way"/ieg; print $test; Output (split on two lines for legibility): ereforeWhay artway outhay, Ovidway, ouyay oronicmay owderheadedchay ellshay ofway away ostghay? iveGay emay ymay leasfay andway eaflay.