in reply to scalar context confusion

The concatenation operator (.) operates on two scalars, so its operand expressions are evaluated in scalar context. In scalar context @list evaluates to the number of elements in @list.

An array name in a double-quoted string is not a Perl expression. It's not evaluated normally. Context cannot be determined from the surrounding code, cause it's not in Perl code. An array name in a double-quoted string is replaced with the result join($", @array), and $" defaults to a space.

Update: Minor tweak to wording for preciseness.
Update: Removed misleading quotes as per reply.

Replies are listed 'Best First'.
Re^2: scalar context confusion
by Narveson (Chaplain) on Feb 28, 2008 at 16:04 UTC
    In scalar context "@list" evaluates to the number of elements in @list.

    I had to view source to see that your quotation marks were outside your code tags. A casual reader might have thought you meant

    In scalar context "@list" evaluates to the number of elements in @list.

    which would have been incorrect, since in scalar context "@list" (quotes in the expression) evaluates to

    malay manab milan anand
      since in scalar context "@list" (quotes in the expression) evaluates to

      Where do you see scalar context in that expression? In scalar context, a string evaluates to a string, because it's a scalar.