in reply to Re: new to perl, syntax question
in thread new to perl, syntax question

print evaluates its operands in list context, so print @name; does not print 3. (print scalar(@name); and print 0+@name; do, though)

Replies are listed 'Best First'.
Re^3: new to perl, syntax question
by tangent (Parson) on Feb 20, 2012 at 13:50 UTC
    Aagh - I did try it before I replied but like this:
    print @name . "\n";
    then I took the "\n" out to make it clearer (but didn't run it!). I take it the concatenation makes print evaluate in scalar context. So should be:
    print "@name"; # prints x y z print @name; # prints xyz print @name . "\n"; # prints 3
    (lidden: I was still fixing this when you replied)

    Update - then I found this:
    If you believe in Lists in Scalar Context, Clap your Hands
    I'll be back in a few weeks.
      Concatenation puts its arguments in scalar context, that is the array is in scalar context.