title: How to edit a line in txt file in perl without using a tmp file
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6063835/need-perl-inplace-editing-of-files-not-on-command-line">Need perl inplace editing of files not on command line</a>  </p>
  </blockquote>
  
  
  
  <p>I have already a working script that edit my log file but i'm using a temporary file, my script working like that:</p>
  
  <pre><code>Open my $in , '&lt;' , $file;
  Open my $out , '&gt;' , $file."tmp";
  
  while ( &lt;in&gt; ){
    print $out $_;
    last if $. == 50;
  }
  
  $line = "testing";
  print $out $line;
  
  while ( &lt;in&gt; ){
    print $out $_;
  }
  
  #Clear tmp file
  close $out;
  unlink $file;
  rename "$file.new", $file;
  </code></pre>
  
  <p>I would like edit my file without creating a tmp file.</p>