in reply to Re^3: map and regexp. An newbie question
in thread map and regexp. An newbie question
No, but I got lucky! See perlop:
If the /r (non-destructive) option is used then it runs the substitution on a copy of the string and instead of returning the number of substitutions, it returns the copy whether or not a substitution occurred. The original string is never changed when /r is used. The copy will always be a plain string, even if the input is an object or a tied variable.
This applies even when /g is being used (otherwise what use would /r be, being that it's non-destructive?).
(Edit: to clarify, no, I didn't try it, but I did upon being chastened, found that it did work, and ran to docs to find out why!)