title: Perl in place editing within a script (rather than one liner)
body: <p>So, I'm used to the <code>perl -i</code> to use perl as I would <code>sed</code> and in place edit. </p>
  
  <p>The docs for <code>$^I</code> in <code>perlvar</code>: </p>
  
  <blockquote>
    <p>$^I
    The current value of the inplace-edit extension. Use undef to disable inplace editing.</p>
  </blockquote>
  
  <p>OK. So this implies that I can perhaps mess around with 'in place' editing in a script? </p>
  
  <p>The thing I'm having trouble with is this:</p>
  
  <p>If I run:</p>
  
  <pre><code>perl -pi -e 's/^/fish/' test_file
  </code></pre>
  
  <p>And then deparse it:</p>
  
  <pre><code>BEGIN { $^I = ""; }
  LINE: while (defined($_ = &lt;ARGV&gt;)) {
      s/^/fish/;
  }
  continue {
      die "-p destination: $!\n" unless print $_;
  }
  </code></pre>
  
  <p>Now - if I were to want to use <code>$^I</code> within a script, say to:</p>
  
  <pre><code> foreach my $file  ( glob "*.csv" ) {
       #inplace edit these files - maybe using Text::CSV to manipulate? 
   }
  </code></pre>
  
  <p>How do I 'enable' this to happen? Is it a question of changing <code>$_</code> (as <code>s/something/somethingelse/</code> does by default) and letting perl implicitly print it? Or is there something else going on? </p>
  
  <p>My major question is - can I do an 'in place edit' that applies a CSV transform (or XML tweak, or similar). </p>
  
  <p>I appreciate I can open separate file handles, read/print etc. I was wondering if there was another way. (even if it is only situationally useful). </p>