title: Why doesn't 'perl -i' change a file in-place?
body: <p>My setup: perl 5.20.2</p>
  
  <p>The file is changed in-place, as expected, with this code:</p>
  
  <pre><code>echo abc &gt; test.txt
  perl -i -ne 's/b/x/;print' test.txt
  </code></pre>
  
  <p>But here, the output is printed to <code>stdout</code> and the file is emptied. Why?</p>
  
  <pre><code>echo abc &gt; test.txt
  perl -i -ne 's/b/x/;push@a,$_;END{print for @a}' test.txt
  </code></pre>