in reply to Re^2: s/// with an empty pattern uses the previous pattern of a s///
in thread s/// with an empty pattern uses the previous pattern of a s///
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: s/// with an empty pattern uses the previous pattern of a s///
by ikegami (Patriarch) on May 17, 2007 at 17:46 UTC | |
|
Re^4: s/// with an empty pattern uses the previous pattern of a s///
by diotalevi (Canon) on May 17, 2007 at 17:50 UTC | |
|
Re^4: s/// with an empty pattern uses the previous pattern of a s///
by jdporter (Paladin) on May 17, 2007 at 18:16 UTC |