title: Getting fixed width columnar output using 'printf' in Perl
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/13038611/formatting-output-with-printf-in-perl">Formatting output with 'printf' in Perl</a>  </p>
  </blockquote>
  
  
  
  <pre><code>my @selections = ("Hamburger","Frankfurter","French Fries","Large Coke","Medium Coke","Small Coke","Onion Rings");
  my @prices = (3.49, 2.19, 1.69, 1.79, 1.59, 1.39, 1.19);
  my @quantity = (3, 0, 0, 4, 0, 0, 8);
  
  printf("%s %10s %12s %10s\n", "Qty", "Desc.", "Unit \$", "Total");
  
  for($meh = 0; $meh &lt;= 6; $meh++)
  {
      if($quantity[$meh] != 0)
      {
          printf("%d %10s %9.2f %7.2f\n", $quantity[$meh], $selections[$meh], $prices[$meh], $prices[$meh]*$quantity[$meh])
      }
  }
  </code></pre>
  
  <p>I can't figure out how to make the columns line up. I followed the suggestions of another post, but it still isn't working.</p>