in reply to Re: Perl interpretor for conditional operator "?"
in thread Perl interpretor for conditional operator "?"

Hello Dave, Thanks for detailed explanation. "The sixth line checks to see if $a is less than $b. It should output the content of @x" I'm newbie, as per my understanding here after expression evaluation @x will be assigned to $var in scalar context and print the no of elements in the array, however it is printing content of array.

  • Comment on Re^2: Perl interpretor for conditional operator "?"

Replies are listed 'Best First'.
Re^3: Perl interpretor for conditional operator "?"
by Corion (Patriarch) on May 22, 2011 at 17:51 UTC

    You misunderstand. Perl makes a difference between @x and "@x".

    $count = @x;

    will assign the number of elements in @x to $count.

    $list = "@x";

    will assign string with all elements of @x separated by comma to $list.

    See perlop for the stringification/interpolation of arrays and the assignment operator.

      Hi Corion, Thank you for the explanation. This clears my understanding. Please ignore my previous update on this thread.