title: How to write wrapped table format in Perl
body: <p>I'm writing in Perl to direct my report in table format but I'm having issue whenever the data filling is texted too long. Is there a way a write the code so that it can wrapped the lines to m ultiple.  Here is my code and output.  Thanks!</p>
  
  <pre><code>printf "\n%-${max1}s %-${max2}s %-15s\n", "====", "====", "=====" ;
  printf "%-${max1}s %-${max2}s %-15s\n", "Code", "Item", "Group" ;
  printf "%-${max1}s %-${max2}s %-15s\n", "====", "====", "=====" ;
  
  foreach my $f (@{$rpt_ptr}) {
  printf "%-${max1}s %-${max2}s %-15s\n", "$$f{code}", "$$f{item}", "$$f{group}", 
  }
  </code></pre>
  
  <p>The output table will be extended to too long if I have the Item list which is too long, ie:-</p>
  
  <pre><code>====  =====                                                                                =====      
  
  Code  Item                                                                                 Group
  
  ====  =====                                                                                =====
  
  A1011 aaaaaa, bbbbb, ccccc, ddddd, eeeee, fffff, ggggg, hhhhh, iiiii, jjjjjj, kkkkk, llll    B
      B101  cccccc                                                                                 A
  </code></pre>
  
  <p>I'm aspected if I can comes out with a table such like:</p>
  
  <pre><code>====  =====                                                                                =====      
  Code  Item                                                                                 Group
  ====  =====                                                                                =====
  A1011 aaaaaa, bbbbb, ccccc, ddddd,                                                           B
        eeeee, fffff, ggggg, hhhhh,   
        iiiii, jjjjjj, kkkkk, llll
  B101  cccccc                                                                                 A
  </code></pre>
  
  <p>How am I going to achieve that?</p>