Prepending to a file

D

Dave

I would like to write something at the begginging of a text file,
without overwriting what is already there.

i.e if the file 'foo' contains

two
three
four

I would like to be able to prepend 'one'

so the file reads

one
two
three
four

How is the best way to do this?

On a UNIX sheel script I could do it by writing the new data (in this
case the word 'one') into another file, then using cat

But I am not sure how to do any of this in perl. I'm using a UNIX
system, and Perl 5.8.6
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top