in reply to Substituting without modifying

That is a method right out of the camel. You have to use the parentheses, otherwise $qux would have the number of times the pattern matched and $foo would be changed. Nothing wrong with my in my opinion