Jayakumar Rajagopal wrote:
($a=3 && $b=6 ) if ( 1 == 1 );
print " $a   $b  \n";

Output : 6 6

This is a precedence problem; the "&&" binds more tightly than the "=" on its left. B::Deparse eliminates some of the constant expressions, but you can see the result:

    % perl -MO=Deparse,-p -e '$a=3 && $b=6'
    ($a = ($b = 6));
    -e syntax OK

Or to break it down another way:

    $a = 3 && $b = 6;
    $a = 3 && 6;
    $a = 6;

Any of these will do what you probably wanted:

    $a = 3 and $b = 6;
    ($a, $b) = (3, 6);
    ($a = 3) && ($b = 6);

--
Steve

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to