title: How do I output a text table in Perl?
body: <p>I want to output a table containing four variables, an example of the desired format is:</p>
  
  <pre><code>A confusion matrix
  
  H        |    P     |
  -----------------------
  $var1    |   $var2  | H
  $var3    |   $var4  | P
  </code></pre>
  
  <p>The problem I am having is that depending on the number of digits in the variables, the format changes and the various lines are offset. I know this is a complete noobie question, but I have never had to pay too much attention to the format of output before, its just one of those little things I want to get right this time. Any help at all would be great, thanks.     </p>