Thank you for these tips. I'm not looking to replace the empty scalar, I'm looking to replace whatever is in that scalar with the value of a different scalar. Those values are determined dynamically so the best answer is to use, as you suggested, something like:
$pat && ($msg =~ s/$pat/$replace/mg);
I was doing some more searching and discovered this exact quote in the perlop man page, as you said in reply #1, however in my copy of the man page it is listed in the m// operator rather than the substitute operator I wasn't aware that it applied there also. It does make sense that it would do, but I have to note this to try to scrape together a little dignity after having just posted a question on something in the man pages like a newbie coder :)
Thanks again for your help! Colin
In reply to Re^3: s/// with an empty pattern uses the previous pattern of a s///
by ckeith100
in thread s/// with an empty pattern uses the previous pattern of a s///
by ckeith100
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |