@@ -2055,15 +2055,16 @@ The bottom line is that using C</o> is almost never a good idea.
2055
2055
=item The empty pattern C<//>
2056
2056
2057
2057
If the I<PATTERN> evaluates to the empty string, the last
2058
- I<successfully> matched regular expression is used instead. In this
2059
- case, only the C<g> and C<c> flags on the empty pattern are honored; the
2060
- other flags are taken from the original pattern. If no match has
2061
- previously succeeded, this will (silently) act instead as a genuine
2062
- empty pattern (which will always match). Using a user supplied string as
2063
- a pattern has the risk that if the string is empty that it triggers the
2064
- "last successful match" behavior, which can be very confusing. In such
2065
- cases you are recommended to replace C<m/$pattern/> with
2066
- C<m/(?:$pattern)/> to avoid this behavior.
2058
+ I<successfully> matched regular expression in the current dynamic
2059
+ scope is used instead (see also L<perlvar/Scoping Rules of Regex Variables>).
2060
+ In this case, only the C<g> and C<c> flags on the empty pattern are
2061
+ honored; the other flags are taken from the original pattern. If no
2062
+ match has previously succeeded, this will (silently) act instead as a
2063
+ genuine empty pattern (which will always match). Using a user supplied
2064
+ string as a pattern has the risk that if the string is empty that it
2065
+ triggers the "last successful match" behavior, which can be very
2066
+ confusing. In such cases you are recommended to replace C<m/$pattern/>
2067
+ with C<m/(?:$pattern)/> to avoid this behavior.
2067
2068
2068
2069
The last successful pattern may be accessed as a variable via
2069
2070
C<${^LAST_SUCCESSFUL_PATTERN}>. Matching against it, or the empty
0 commit comments