title: What's the best way to conditionally include an element in a list?
body: <p>Possible ways:</p>
  
  <ol>
  <li><p>Using <a href="http://perldoc.perl.org/functions/push.html" rel="nofollow noreferrer">push</a>:</p>
  
  <pre><code>my @list;  
  push @list, 'foo' if $foo;  
  push @list, 'bar' if $bar;  
  </code></pre></li>
  <li><p>Using the <a href="http://perldoc.perl.org/perlop.html#Conditional-Operator" rel="nofollow noreferrer">conditional operator</a>:    </p>
  
  <pre><code>my @list = (  
      $foo ? 'foo' : (),    
      $bar ? 'bar' : (),              
  );
  </code></pre></li>
  <li><p>Using the <a href="http://www.perlmonks.org/?node_id=564792" rel="nofollow noreferrer"><code>x!!</code> Boolean list squash operator</a>:</p>
  
  <pre><code>my @list = (  
      ('foo') x!! $foo,  
      ('bar') x!! $bar,  
  );  
  </code></pre></li>
  </ol>
  
  <p>Which one is better and why?</p>