title: How can I enable/disable perl's edit-in-place feature?
body: <p>If I invoke perl with the <code>-i</code> flag, it will edit input files in place; <code>i.bak</code> will create a backup with the extension <code>.bak</code>. But this requires me to either put <code>#!/usr/bin/perl -i</code> in my script, or explicitly use <code>perl -i</code> on the command line.</p>
  
  <p>I would like my script itself to control if/when this happens. Is there a way to programmatically activate this perl feature, e.g., by modifying perl's idea of how it was invoked, or by setting a special variable?</p>
  
  <p>Two workarounds I already know about:</p>
  
  <ul>
  <li><p>I could invoke perl from the command line: <code>perl -i.bak ~/bin/myscript</code>. But I want to be able to just type <code>myscript</code>.</p></li>
  <li><p>I could implement in-place editing from scratch. If there's no way to trigger the built-in version, this is what I'll probably do.</p></li>
  </ul>