From 4f4d7508b0c2c114e5f52420e0e87a853c5f642a Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 23 Nov 2009 17:24:25 -0800 Subject: 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. --- regexp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'regexp.h') diff --git a/regexp.h b/regexp.h index 502259fdb1..758bdbe1e5 100644 --- a/regexp.h +++ b/regexp.h @@ -263,11 +263,13 @@ and check for NULL. #define SINGLE_PAT_MOD 's' #define IGNORE_PAT_MOD 'i' #define XTENDED_PAT_MOD 'x' +#define NONDESTRUCT_PAT_MOD 'r' #define ONCE_PAT_MODS "o" #define KEEPCOPY_PAT_MODS "p" #define EXEC_PAT_MODS "e" #define LOOP_PAT_MODS "gc" +#define NONDESTRUCT_PAT_MODS "r" #define STD_PAT_MODS "msix" @@ -276,7 +278,7 @@ and check for NULL. #define EXT_PAT_MODS ONCE_PAT_MODS KEEPCOPY_PAT_MODS #define QR_PAT_MODS STD_PAT_MODS EXT_PAT_MODS #define M_PAT_MODS QR_PAT_MODS LOOP_PAT_MODS -#define S_PAT_MODS M_PAT_MODS EXEC_PAT_MODS +#define S_PAT_MODS M_PAT_MODS EXEC_PAT_MODS NONDESTRUCT_PAT_MODS /* * NOTE: if you modify any RXf flags you should run regen.pl or regcomp.pl -- cgit v1.2.1