This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade IO::Compress::* and Compress::Raw::* from 2.061 to 2.062
[perl5.git] / pod / perlre.pod
index 0119fc5..404fc31 100644 (file)
@@ -111,6 +111,15 @@ These modifiers, all new in 5.14, affect which character-set semantics
 (Unicode, etc.) are used, as described below in
 L</Character set modifiers>.
 
+=item r
+X</r>
+
+Non-destructive substitution.  Unlike regular substitution, the entity to
+which the substitution is bound is B<not> modified in place.  Rather, the
+B<result> of the substitution is returned as a plain string.  See
+L<perlop/"s/PATTERN/REPLACEMENT/msixpodualgcer"> for further explanation of
+the C</r> modifier.
+
 =back
 
 Regular expression modifiers are usually written in documentation
@@ -746,6 +755,17 @@ row.
 It is worth noting that C<\G> improperly used can result in an infinite
 loop. Take care when using patterns that include C<\G> in an alternation.
 
+Note also that C<s///> will refuse to overwrite part of a substitution
+that has already been replaced; so for example this will stop after the
+first iteration, rather than iterating its way backwards through the
+string:
+
+    $_ = "123456789";
+    pos = 6;
+    s/.(?=.\G)/X/g;
+    print;     # prints 1234X6789, not XXXXX6789
+
+
 =head3 Capture groups
 
 The bracketing construct C<( ... )> creates capture groups (also referred to as