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 /dist | |
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 'dist')
-rw-r--r-- | dist/B-Deparse/Deparse.pm | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index fc0125d62f..16b5642e34 100644 --- a/dist/B-Deparse/Deparse.pm +++ b/dist/B-Deparse/Deparse.pm @@ -19,7 +19,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring OPpREVERSE_INPLACE SVf_IOK SVf_NOK SVf_ROK SVf_POK SVpad_OUR SVf_FAKE SVs_RMG SVs_SMG CVf_METHOD CVf_LVALUE - PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE + PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_NONDESTRUCT PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED), ($] < 5.009 ? 'PMf_SKIPWHITE' : 'RXf_SKIPWHITE'), ($] < 5.011 ? 'CVf_LOCKED' : ()); @@ -4310,7 +4310,9 @@ my %substwords; map($substwords{join "", sort split //, $_} = $_, 'ego', 'egoism', 'em', 'es', 'ex', 'exes', 'gee', 'go', 'goes', 'ie', 'ism', 'iso', 'me', 'meese', 'meso', 'mig', 'mix', 'os', 'ox', 'oxime', 'see', 'seem', - 'seg', 'sex', 'sig', 'six', 'smog', 'sog', 'some', 'xi'); + 'seg', 'sex', 'sig', 'six', 'smog', 'sog', 'some', 'xi', + 'sir', 'rise', 'smore', 'more', 'seer', 'rome', 'gore', 'grim', 'grime', + 'or', 'rose', 'rosie'); sub pp_subst { my $self = shift; @@ -4351,6 +4353,7 @@ sub pp_subst { ($re) = $self->regcomp($kid, 1, $extended); } $flags .= "e" if $op->pmflags & PMf_EVAL; + $flags .= "r" if $op->pmflags & PMf_NONDESTRUCT; $flags .= "g" if $op->pmflags & PMf_GLOBAL; $flags .= "i" if $op->pmflags & PMf_FOLD; $flags .= "m" if $op->pmflags & PMf_MULTILINE; |