http://www.perlmonks.org?node_id=476386


in reply to Modify file without any temp variable

Hi

use strict; my $ou; open(JE, "+<c:\\tuls\\tuls.txt"); while(<JE>) { $_=~s/findtext/changetext/g; $ou.=$_; } seek(JE, 0, 0); print JE $ou; close JE

Replies are listed 'Best First'.
Re^2: Modify file without any temp variable
by Pied (Monk) on Jun 20, 2007 at 23:10 UTC
    This is bad ! If the new text is shorter than the old one, the file is not truncated, and you happen to have some extra dirt at the end of the file ! (took me quite some time to figure it out)

    P!

    Are the monkeys gone yet?