2009/7/21 Bram <p5p@perl.wizbit.be>:
> This seem to happen because given creates a lexical $_. It also happens when
> for/foreach is used with a lexical $_:
Hmm what ? No, given does not create a lexical $_ : from pp_entergiven :
if (PL_op->op_targ == 0) {
SV ** const defsv_p = &GvSV(PL_defgv);
*defsv_p = newSVsv(POPs);
SAVECLEARSV(*defsv_p);
}
else
sv_setsv(PAD_SV(PL_op->op_targ), POPs);
(rewriting that with the proper macros will be nice) (not sure if
there is absolutely no bug there)
What happens, at first glance, it that List::Util always uses the
global $_. (an "our $_" in the "first" block should solve the pb).
We provide UNDERBAR and dUNDERBAR macros to access the current $_, be
it lexical or global.
However we don't have (yet) an API to localize the current $_ as
needed in grep-like functions.
I suppose that code from pp_grepstart could be copied in List::Util to
solve the bug.
Thread Previous
|
Thread Next