summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-01-02 19:38:30 +0000
committerDavid Mitchell <davem@iabyn.com>2011-01-02 20:00:27 +0000
commit9426e1a55981168c83a030df9bce5e0b46586581 (patch)
tree9693090582930b7f145f2050c847bd2f87f9ed0d /pp_sys.c
parentbff33ce02f3be5fbb5af2c3c92e9853aaa12151e (diff)
downloadperl-9426e1a55981168c83a030df9bce5e0b46586581.tar.gz
make <expr> always overload if expr is overloaded
Due to the way that '<> as glob' was parsed differently from '<> as filehandle' from 5.6 onwards, something like <$foo[0]> didn't handle overloading, even where $foo[0] was an overloaded object. This was contrary to the docs for overload, and meant that <> couldn't be used as a general overloaded iterator operator.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 7144bc3725..a657d3632f 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -358,6 +358,12 @@ PP(pp_glob)
{
dVAR;
OP *result;
+ dSP;
+ /* make a copy of the pattern, to ensure that magic is called once
+ * and only once */
+ TOPm1s = sv_2mortal(newSVsv(TOPm1s));
+
+ tryAMAGICunTARGET(iter_amg, -1, (PL_op->op_flags & OPf_SPECIAL));
if (PL_op->op_flags & OPf_SPECIAL) {
/* call Perl-level glob function instead. Stack args are:
@@ -368,7 +374,6 @@ PP(pp_glob)
}
/* stack args are: wildcard, gv(_GEN_n) */
- tryAMAGICunTARGET(iter_amg, -1);
/* Note that we only ever get here if File::Glob fails to load
* without at the same time croaking, for some reason, or if