PP(pp_grepwhile)
...
if (gimme == G_SCALAR) { // Scalar context
dTARGET;
XPUSHi(items); // Choose the scalar that gets returned.
}
else if (gimme == G_ARRAY)
SP += items;
RETURN;
}
...
####
c:\test>perl -MO=Concise -wle"print scalar( 1, 2, 3 );"
Useless use of a constant in void context at -e line 1.
8 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
7 <@> print vK ->8
3 <0> pushmark s ->4
- <1> scalar sK/1 ->7
6 <@> list sK ->7 <<< And yet, there it is.
4 <0> pushmark v ->5
- <0> ex-const v ->-
- <0> ex-const v ->5
5 <$> const[IV 3] s ->6
-e syntax OK
####
c:\test>perl -wle"print for ( 'a','b','c' )"
a
b
c
####
c:\test>perl -wle"print for scalar(( 'a','b','c' ))"
Useless use of a constant in void context at -e line 1.
Useless use of a constant in void context at -e line 1.
c
####
c:\test>perl -wle"print for scalar 'a','b','c'"
a
b
c
c:\test>perl -wle"@a = (1,2,3); print for @a"
1
2
3
c:\test>perl -wle"@a = 1,2,3; print for @a"
Useless use of a constant in void context at -e line 1.
Useless use of a constant in void context at -e line 1.
1
####
PP(pp_aslice)
{
dSP; dMARK; dORIGMARK;
register AV* const av = (AV*)POPs;
register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
if (SvTYPE(av) == SVt_PVAV) {
const I32 arybase = PL_curcop->cop_arybase;
if (lval && PL_op->op_private & OPpLVAL_INTRO) {
register SV **svp;
I32 max = -1;
for (svp = MARK + 1; svp <= SP; svp++) {
const I32 elem = SvIVx(*svp);
if (elem > max)
max = elem;
}
if (max > AvMAX(av))
av_extend(av, max);
}
while (++MARK <= SP) {
register SV **svp;
I32 elem = SvIVx(*MARK);
if (elem > 0)
elem -= arybase;
svp = av_fetch(av, elem, lval);
if (lval) {
if (!svp || *svp == &PL_sv_undef)
DIE(aTHX_ PL_no_aelem, elem);
if (PL_op->op_private & OPpLVAL_INTRO)
save_aelem(av, elem, svp);
}
*MARK = svp ? *svp : &PL_sv_undef;
}
}
if (GIMME != G_ARRAY) {
MARK = ORIGMARK;
*++MARK = SP > ORIGMARK ? *SP : &PL_sv_undef;
SP = MARK;
}
RETURN;
}