Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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


Comment on Re: Modify file without any temp variable
Download Code
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 meditating upon the Monastery: (6)
As of 2014-09-21 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (165 votes), past polls