title: Piping Perl script output to head -n 10 kills script after printing 10 lines
body: <p>My Perl script outputs and logs many lines of text, and it does some cleanup and compresses some logs in an <code>END</code> block.</p>
  
  <p>The problem is when you do something like this on the command line:</p>
  
  <pre><code>perl myscript.pl | head -n 10
  </code></pre>
  
  <p>This causes the script to die as soon as it outputs 10 lines, so the <code>END</code> block doesn't get executed and the logs don't get compressed. Is there a way to get around this and make sure the code in my <code>END</code> block is still executed?</p>