title: Formatting output with 'printf' in Perl
body: <p>I'm trying to format my output to look like it's in columns. I'm trying to use the <a href="http://perldoc.perl.org/functions/printf.html" rel="nofollow">printf</a> function.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>printf("%s %10s %12s %10s\n", "Qty", "Desc.", "Unit \$", "Total");
  
  for ($he = 0; $he &lt;= 6; $he++) {
      if (@quantity[$he] != 0) {
          printf("%d %10s %12.2f %10.2f\n", @quantity[$he], @selections[$he], @prices[$he], @prices[$he] * @quantity[$he])
      }
  }
  </code></pre>
  
  <p>I'm trying to make it so that the second printf inside of the <code>if</code> statement of the <code>for</code> loop lines up with the "Qty", "Desc.", "Unit \$" and "Total."</p>