Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Modify file without any temp variable

by gopalr (Priest)
on Jul 20, 2005 at 07:15 UTC ( #476386=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://476386]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2016-08-30 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (420 votes). Check out past polls.