Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using read/write to update a file

by MidLifeXis (Monsignor)
on Oct 14, 2014 at 18:53 UTC ( [id://1103790]=note: print w/replies, xml ) Need Help??


in reply to Using read/write to update a file

You will likely need seek, tell, print (with a filehandle argument), and possibly truncate.

Unless the replacement is the same length or shorter (and even then you still might), you will also need to write to a temporary file, and not just the original file, doing a rename after closing both files. If you do not (or if you don't use the Tie::File suggestion above), you risk corruption or truncation of the data file.

--MidLifeXis

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2024-03-28 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found