Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Advanced appending to file

by chime (Friar)
on Jul 13, 2004 at 14:37 UTC ( [id://374017]=note: print w/replies, xml ) Need Help??


in reply to Advanced appending to file

Seek and tell are what you need for moving output around a file
# Open existing file open(FILE, "+<filename.txt") || or die "error: $!"; seek(FILE, 0, 2); # seek to the end of the file print FILE "On the end"; # Appended to the end of the file seek (FILE, 0, 0); # seek to the begining of the file print File "At the begining"; my $point = tell(FILE); # tell where you are in the file # Here tell will be 15 becuase you are at the end of "At the begining"
These are all in the perlfunc docs

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-16 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found