From 050872cb6a4482e730d11e229ebc0eb4cb6ef90d Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Tue, 31 Oct 2023 19:30:52 +0100 Subject: [PATCH] Mention that the regex used by the empty m// is scoped --- pod/perlop.pod | 19 ++++++++++--------- pod/perlvar.pod | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pod/perlop.pod b/pod/perlop.pod index 1221fe960798..bcb03dd1780c 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -2055,15 +2055,16 @@ The bottom line is that using C is almost never a good idea. =item The empty pattern C If the I evaluates to the empty string, the last -I matched regular expression is used instead. In this -case, only the C and C flags on the empty pattern are honored; the -other flags are taken from the original pattern. If no match has -previously succeeded, this will (silently) act instead as a genuine -empty pattern (which will always match). Using a user supplied string as -a pattern has the risk that if the string is empty that it triggers the -"last successful match" behavior, which can be very confusing. In such -cases you are recommended to replace C with -C to avoid this behavior. +I matched regular expression in the current dynamic +scope is used instead (see also L). +In this case, only the C and C flags on the empty pattern are +honored; the other flags are taken from the original pattern. If no +match has previously succeeded, this will (silently) act instead as a +genuine empty pattern (which will always match). Using a user supplied +string as a pattern has the risk that if the string is empty that it +triggers the "last successful match" behavior, which can be very +confusing. In such cases you are recommended to replace C +with C to avoid this behavior. The last successful pattern may be accessed as a variable via C<${^LAST_SUCCESSFUL_PATTERN}>. Matching against it, or the empty diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 3f86b67567ca..a2b0abfbdcdb 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -967,6 +967,7 @@ documented as behaving otherwise. See the following section for more details. =head3 Scoping Rules of Regex Variables +X Regular expression variables allow the programmer to access the state of the most recent I regex match in the current dynamic scope.