title: How do I write text in aligned columns in Perl?
body: <p>I am trying to write to a file from Perl. I just want to write the data in a tab-delimited format. However, the data that I am writing has varying lengths and is not lining up.</p>
  <p>For example, I am trying to write something like this:</p>
  <pre><code>Name  Education   Fav_Car  MoneyInBank
  josh  High School Porche   500
  SomeOtherName  PHD  Hyundai   50000
  </code></pre>
  <p>I just want the data to be lined up with the headers that I have on the top.</p>
  <p>I am outputting the data like so:</p>
  <pre><code> printf FILE (&quot;%s%20s%20s\n&quot;, &quot;Name&quot;, &quot;Ed&quot;, &quot;Car&quot;);
   while (($name, $ed, $car) = $sth-&gt;fetchrow_array) {
       printf FILE (&quot;%s&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;%40s%40s\n&quot;, $name, $ed, $car);
   };
  </code></pre>