in reply to Re: arrays, context, and print - oh my.
in thread arrays, context, and print - oh my.

print scalar (1,2,3,4)[2];
Doesn't work, because you seem to want the scalar value of an array (it's size), but you're specifying a list.

I think that you are wrong on this one, notice:

print scalar (1,2,3,4)[2]; # syntax error at )[ print scalar((1,2,3,4)[2] ); # prints 3 print scalar+(1,2,3,4)[2]; # also prints 3

Your first answer applies to both. The scalar is just hogging the parens. It is also useless, as it is forcing a scalar context on a scalar.

Replies are listed 'Best First'.
Re^3: arrays, context, and print - oh my.
by phaylon (Curate) on Aug 09, 2005 at 13:58 UTC
    Yep. You're right :)

    Ordinary morality is for ordinary people. -- Aleister Crowley