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?
[Discipulus]: my whishlist include more "elements" anyway

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-02-24 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (353 votes). Check out past polls.