Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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


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)


    Are the monkeys gone yet?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2016-06-26 00:49 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (327 votes). Check out past polls.