diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-24 12:40:13 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-24 12:40:13 +0000 |
commit | b9ac3b5bccebb018cd8247aa730731b1cbd8a6d4 (patch) | |
tree | 50f4e7ba591f510d684b70b66c647234686fa720 /pod | |
parent | 9666903d92ab8cdd420a0bc714d5c94ce051cb2c (diff) | |
download | perl-b9ac3b5bccebb018cd8247aa730731b1cbd8a6d4.tar.gz |
check in what change#1182 didn't, and Changes
p4raw-link: @1182 on //depot/perl: c7c9307cc294d88bccf6b755e886fdee7d955ee0
p4raw-id: //depot/perl@1212
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perlre.pod | 30 | ||||
-rw-r--r-- | pod/perlvar.pod | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/pod/perlre.pod b/pod/perlre.pod index b8c566228a..ebd58582d0 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -329,6 +329,36 @@ Experimental "evaluate any Perl code" zero-width assertion. Always succeeds. C<code> is not interpolated. Currently the rules to determine where the C<code> ends are somewhat convoluted. +The C<code> is properly scoped in the following sense: if the assertion +is backtracked (compare L<"Backtracking">), all the changes introduced after +C<local>isation are undone, so + + $_ = 'a' x 8; + m< + (?{ $cnt = 0 }) # Initialize $cnt. + ( + a + (?{ + local $cnt = $cnt + 1; # Update $cnt, backtracking-safe. + }) + )* + aaaa + (?{ $res = $cnt }) # On success copy to non-localized + # location. + >x; + +will set C<$res = 4>. Note that after the match $cnt returns to the globally +introduced value 0, since the scopes which restrict C<local> statements +are unwound. + +This assertion may be used as L<C<(?(condition)yes-pattern|no-pattern)>> +switch. If I<not> used in this way, the result of evaluation of C<code> +is put into variable $^R. This happens immediately, so $^R can be used from +other C<(?{ code })> assertions inside the same regular expression. + +The above assignment to $^R is properly localized, thus the old value of $^R +is restored if the assertion is backtracked (compare L<"Backtracking">). + B<WARNING>: This is a grave security risk for arbitrarily interpolated patterns. It introduces security holes in previously safe programs. A fix to Perl, and to this documentation, will be forthcoming prior diff --git a/pod/perlvar.pod b/pod/perlvar.pod index d10fe35cbd..2ed3e97f77 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -717,6 +717,12 @@ Start with single-step on. Note that some bits may be relevent at compile-time only, some at run-time only. This is a new mechanism and the details may change. +=item $^R + +The result of evaluation of the last successful L<perlre/C<(?{ code })>> +regular expression assertion. (Excluding those used as switches.) May +be written to. + =item $^S Current state of the interpreter. Undefined if parsing of the current |