title: List Operator Precedence in Perl
body: <p>I'm reading the "Beginning Perl" book, and it gives these two statements:</p>
  
  <pre><code>print "Test one: ", 6 &gt; 3 &amp;&amp; 3 &gt; 4, "\n";
  print "Test two: ", 6 &gt; 3 and 3 &gt; 4, "\n";
  </code></pre>
  
  <p>The first line prints nothing with a new line, the second line prints a 1 with no new line.</p>
  
  <p>I'm confused about the output. According to the author, the second statement gives weird output because it's just like saying:</p>
  
  <pre><code>print ("Test two: ", 6 &gt; 3) and 3 &gt; 4, "\n";
  </code></pre>
  
  <p>However, why is the first statement not the same? I thought it had something to do with print's precedence. The &amp;&amp; has higher precedence than print, so that's evaluated first and then it's printed. Whereas the "and" has lower precedence than print, so 6 > 3 will be printed, print returns a 1, and then that is evaluated with the "and." However this doesn't really make sense.</p>
  
  <p>I've read the Perl documentation on how precedence works for list operators, but I still do not understand this example. Can you guys dissect the two statements, and tell me what is printed first? Can you also explain what the Perl documentation means when it mentions list operators as being "leftward" and "rightward?" Thanks.</p>
  
  <hr>
  
  <p>Thanks a lot everyone for your answers. I understand it now. I was indeed doing what cjm said, and thinking that there are leftward and rightward list operators. So now that I understand what it means, I understand the whole thing.</p>