From: Gerard Goossen Date: Tue, 27 Oct 2009 20:59:34 +0000 (+0100) Subject: Improve warnings about known issues in (?{...}) blocks in the regex engine X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e95d73140218cc53e63e359a04270e05457c786f;p=p5sagit%2Fp5-mst-13.2.git Improve warnings about known issues in (?{...}) blocks in the regex engine --- diff --git a/pod/perlre.pod b/pod/perlre.pod index 58c3dc7..df627ff 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -946,13 +946,6 @@ The assignment to C<$^R> above is properly localized, so the old value of C<$^R> is restored if the assertion is backtracked; compare L<"Backtracking">. -Due to an unfortunate implementation issue, the Perl code contained in these -blocks is treated as a compile time closure that can have seemingly bizarre -consequences when used with lexically scoped variables inside of subroutines -or loops. There are various workarounds for this, including simply using -global variables instead. If you are using this construct and strange results -occur then check for the use of lexically scoped variables. - For reasons of security, this construct is forbidden if the regular expression involves run-time interpolation of variables, unless the perilous C pragma has been used (see L), or the @@ -974,9 +967,15 @@ so you should only do so if you are also using taint checking. Better yet, use the carefully constrained evaluation within a Safe compartment. See L for details about both these mechanisms. -Because Perl's regex engine is currently not re-entrant, interpolated -code may not invoke the regex engine either directly with C or C), -or indirectly with functions such as C. +B: Use of lexical (C) variables in these blocks is +broken. The result is unpredictable and will make perl unstable. The +workaround is to use global (C) variables. + +B: Because Perl's regex engine is currently not re-entrant, +interpolated code may not invoke the regex engine either directly with +C or C), or indirectly with functions such as +C. Invoking the regex engine in these blocks will make perl +unstable. =item C<(??{ code })> X<(??{})>