On Fri, Sep 21, 2001 at 03:16:53AM -0700, Dave Cross said:

> My experience is that most people first get the right answer
> for the wrong reason, then the wrong answer for the right(ish)
> reason and finally the right anser for the right reason.

Hmm. Is this right?

>From perldoc perlop

    @ary = (1, 3, sort 4, 2);
           print @ary;         # prints 1324

       the commas on the right of the sort are evaluated before
       the sort, but the commas on the left are evaluated after.
       In other words, list operators tend to gobble up all
       arguments that follow, and then act like a simple TERM
       with regard to the preceding expression.  Be careful with
       parentheses:

           # These evaluate exit before doing the print:
           print($foo, exit);  # Obviously not what you want.
           print $foo, exit;   # Nor is this.

           # These do the print before evaluating exit:
           (print $foo), exit; # This is what you want.
           print($foo), exit;  # Or this.
           print ($foo), exit; # Or even this.

so what happens is that anything right of the first comma is evaluated after
(because comma is left associative) and in this case acts like a 

1;

at the end of a module.

It's almost like doing a && operator and chainging commands together.

Thus leaving the first value to be assigned to the scalar.

These two can be shown by doing 

% perl
$i = 1, 2, 3;
print $i,"\n";
1
%

% perl 
$i = 2 , 3;
print $i,"\n";
2
%

% perl
$i = 3, $i-=2;
print $i,"\n";
1
%



-- 
: nature notes for the apocalypse

Reply via email to