in reply to Re: 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///
Oh! Another to fix the problem is to add a no-op to the regexp.
$\ = "\n"; $pat = 'b'; $_='abc'; s/$pat/!/g; print; $pat = ''; $_='abc'; s/$pat/@/g; print; $pat = ''; $_='abc'; s/(?:$pat)/#/g; print;
outputs
a!c a@c #a#b#c#
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: s/// with an empty pattern uses the previous pattern of a s///
by ckeith100 (Initiate) on May 17, 2007 at 16:25 UTC | |
by ikegami (Patriarch) on May 17, 2007 at 17:46 UTC | |
by diotalevi (Canon) on May 17, 2007 at 17:50 UTC | |
by jdporter (Paladin) on May 17, 2007 at 18:16 UTC |