Perldoc Search: "$^R" perl-5.20.1

search official POD

4 PODs, 10 LINEs found.
643 :         This zero-width assertion executes any embedded Perl code. It always succeeds, and its return value is set as $^R.
712 :         switch. If *not* used in this way, the result of evaluation of "code" is put into the special variable $^R. This happens immediately, so $^R can be used from other "(?{ code })" assertions inside the same regular expression.
714 :         The assignment to $^R above is properly localized, so the old value of $^R is restored if the assertion is backtracked; compare "Backtracking".
725 :         This is a "postponed" regular subexpression. It behaves in *exactly* the same way as a "(?{ code })" code block as described above, except that its return value, rather than being assigned to $^R, is treated as a pattern, compiled if it's a string (or used as-is if its a qr// object), then matched as if it were inserted instead of this construct.
1355 :     Code expressions are zero-width assertions, and the value they return depends on their environment. There are two possibilities: either the code expression is used as a conditional in a conditional expression "(?(condition)...)", or it is not. If the code expression is a conditional, the code is evaluated and the result (i.e., the result of the last statement) is used to determine truth or falsehood. If the code expression is not used as a conditional, the assertion always evaluates true and the result is put into the special variable $^R. The variable $^R can then be used in code expressions later in the regexp. Here are some silly examples:
1386 :         $x =~ /(?{$c = 1;})(?{print "$^R";})/; # matches,
1423 :     The result $^R is automatically localized, so that it will behave properly in the presence of backtracking.
216 :        (?{ code })       Embedded code, return value becomes $^R
254 :        $^R   Holds the result of the last (?{...}) expr
602 :     $^R     The result of evaluation of the last successful "(?{ code })" regular expression assertion (see perlre). May be written to.
<< Back to Perldoc Search