summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-10 13:23:34 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-10 13:28:07 -0800
commita289ef89aea304cdebfa085e4451b1c02cb33648 (patch)
treefe69a0f5a42fdcb453ed6d97d99912cbe2d2139b /gv.c
parentd29a1dbb963b505f2020c99fdcc6a99d14c5f206 (diff)
downloadperl-a289ef89aea304cdebfa085e4451b1c02cb33648.tar.gz
[perl #24237] @& should not stop $& from working
Mentioning $& in a program slows everything down, because it force regular expressions to do a pre-match copy. It used to happen for any symbol named &, e.g., @& and %&. This was changed in commit b4a9608f339, but that commit did not take into account that the code path in question is only followed on creation of the *& glob. It should still be applying magic to $&, even if it is not setting PL_sawampersand. The other place in gv_fetchpvn_flags that magical- ises scalars (which currently handles %- %+ %! $] and @ISA), should also turn on PL_sawampersand for $&. All of the above applies to $' and $` as well.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gv.c b/gv.c
index df3735a105..4b4d9a6529 100644
--- a/gv.c
+++ b/gv.c
@@ -1650,8 +1650,14 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
else if (*name == '-' || *name == '+')
require_tie_mod(gv, name, newSVpvs("Tie::Hash::NamedCapture"), "TIEHASH", 0);
}
- if ((sv_type==SVt_PV || sv_type==SVt_PVGV) && *name == '[')
+ if (sv_type==SVt_PV || sv_type==SVt_PVGV) {
+ if (*name == '[')
require_tie_mod(gv,name,newSVpvs("arybase"),"FETCH",0);
+ else if (*name == '&' || *name == '`' || *name == '\'') {
+ PL_sawampersand = TRUE;
+ (void)GvSVn(gv);
+ }
+ }
}
else if (len == 3 && sv_type == SVt_PVAV
&& strnEQ(name, "ISA", 3)
@@ -1859,14 +1865,13 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
case '&': /* $& */
case '`': /* $` */
case '\'': /* $' */
- if (
+ if (!(
sv_type == SVt_PVAV ||
sv_type == SVt_PVHV ||
sv_type == SVt_PVCV ||
sv_type == SVt_PVFM ||
sv_type == SVt_PVIO
- ) { break; }
- PL_sawampersand = TRUE;
+ )) { PL_sawampersand = TRUE; }
goto magicalize;
case ':': /* $: */