diff options
author | David Caldwell <david@porkrind.org> | 2009-11-23 17:24:25 -0800 |
---|---|---|
committer | David Caldwell <david@porkrind.org> | 2010-05-22 02:28:22 -0700 |
commit | 4f4d7508b0c2c114e5f52420e0e87a853c5f642a (patch) | |
tree | 008d80915d83e246892b83fa06e46a3b2e21c6bf /pp_ctl.c | |
parent | dd9035cd5bdeced1187df399d27d526f3b30194b (diff) | |
download | perl-4f4d7508b0c2c114e5f52420e0e87a853c5f642a.tar.gz |
Add s///r (non-destructive substitution).
This changes s/// so that it doesn't act destructively on its target.
Instead it returns the result of the substitution (or the original string if
there was no match).
In addition this patch:
* Adds a new warning when s///r happens in void context.
* Adds a error when you try to use s///r with !~
* Makes it so constant strings can be bound to s///r with =~
* Adds documentation.
* Adds some tests.
* Updates various debug code so it knows about the /r flag.
* Adds some new 'r' words to B::Deparse.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -325,7 +325,10 @@ PP(pp_substcont) SvPV_set(dstr, NULL); TAINT_IF(cx->sb_rxtainted & 1); - mPUSHi(saviters - 1); + if (pm->op_pmflags & PMf_NONDESTRUCT) + PUSHs(targ); + else + mPUSHi(saviters - 1); (void)SvPOK_only_UTF8(targ); TAINT_IF(cx->sb_rxtainted); |