title: Perl: Trim multi-line records
body: <p>I need to read in multi-line records and trim them down to exactly 40 lines. Then
  pad them to be 45 lines. They might be as large as 70 + lines. These records need
  to end up being 45 lines. </p>
  
  <p>The record separator is a line beginning with the pattern /^#matchee/.</p>
  
  <p>I'm assuming you'd set $/ to #matchee.</p>
  
  <pre><code>{
      $/ = "#matchee";
  
      while (&lt;&gt;) {
          # I need to print first 40
          # lines of each record then
          # pad to 45 with delimiter as
          # last line.
      }
  }
  </code></pre>
  
  <p>Sample record</p>
  
  <pre><code>REDUNDANCY DEPARTMENT
  Anonymous Ave
  
  Item 1
  Item 2
  
  
  
  &lt;bunch of blank lines&gt;
  #matchee
  </code></pre>