Possible Duplicate:
Need perl inplace editing of files not on command line
I have already a working script that edit my log file but i’m using a temporary file, my script working like that:
Open my $in , '<' , $file;
Open my $out , '>' , $file."tmp";
while ( <in> ){
print $out $_;
last if $. == 50;
}
$line = "testing";
print $out $line;
while ( <in> ){
print $out $_;
}
#Clear tmp file
close $out;
unlink $file;
rename "$file.new", $file;
I would like edit my file without creating a tmp file.
Use the inplace-editing magic: