in reply to Re^2: difference between array and list in perl
in thread difference between array and list in perl

> there are no lists in scalar context

This is - as usual - a definition conflict!

As I already pointed out there are (at least) two widespread interpretations of what "LIST" mean:

  • a literal comma separated sequence of expressions visible in source code
  • the realization for passing theses values at run time through an internal stack

    Take this example code:

     perl -e 'print scalar ($a++,"b","c"), $a'

    Following your explanation one might think that $a should never be incremented, since the "list" (the stack) is never built!

    But actually one gets c1 as output, since the "list" (the sequence) is evaluated step by step

    Cheers Rolf

    UPDATE: shortened post

  • Replies are listed 'Best First'.
    Re^4: difference between array and list in perl
    by JavaFan (Canon) on Jan 17, 2010 at 14:13 UTC
      the realization for passing theses values at run time through an internal stack
      Don't confuse implementation (perl) with the language (Perl)! Otherwise, you'd have to start claiming Perl has pointers!
      perl -e 'print scalar ($a++,"b","c"), $a'

      Following your explanation one might think that $a should never be incremented, since the "list" (the stack) is never built!

      Bollocks! What you have here is the scalar comma operator. From perlop:
      Binary "," is the comma operator. In scalar context it evaluates its left argument, throws that value away, then evaluates its right argument and returns that value. This is just like C’s comma operator.