title: When do you need to `END { close STDOUT}` in Perl?
body: <p>In the <a href="https://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/6163129#6163129">tchrists broilerplate</a> i found this explicit closing of STDOUT in the END block.</p>
  
  <pre><code>END { close STDOUT }
  </code></pre>
  
  <p>I know END and close, but i'm missing why it is needed.</p>
  
  <p>When start searching about it, found in the <a href="http://perldoc.perl.org/perlfaq8.html" rel="nofollow noreferrer">perlfaq8</a> the following:</p>
  
  <blockquote>
    <p>For example, you can use this to make
    sure your filter program managed to
    finish its output without filling up
    the disk:</p>
  </blockquote>
  
  <pre><code>END {
      close(STDOUT) || die "stdout close failed: $!";
  }
  </code></pre>
  
  <p><strong>and don't understand it anyway. :(</strong></p>
  
  <p>Can someone explain (maybe with some code-examples):</p>
  
  <ul>
  <li>why and when it is needed</li>
  <li>how and in what cases can my perl filter fill up the disk  and so on.</li>
  <li>when things getting wrong without it...</li>
  <li>etc??</li>
  </ul>