can I modify a file without using a temporary file

L

Lin Jingxian

hi,
I want to modify contents of a file. usually I will open the file,read the
contents,
do some substitution, and write them to a temporary file, then delete the
original file,
rename the temporary file to the original file.
now I want not to use a temporary file, can I do it in perl ?

thanks.
 
J

Jürgen Exner

Lin said:
hi,
I want to modify contents of a file. usually I will open the
file,read the contents,
do some substitution, and write them to a temporary file, then delete
the original file,
rename the temporary file to the original file.
now I want not to use a temporary file, can I do it in perl ?

Sure, just open() the file for read and write and then seek() to whereever
you want to write.

jue
 
T

Tad McClellan

Lin Jingxian said:
I want to modify contents of a file.


perldoc -q file

How do I change one line in a file/delete a line in a file/insert a
line in the middle of a file/append to the beginning of a file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top