in reply to Appending to the beginning of a 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?

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Appending to the embeginning/em of a file.

Replies are listed 'Best First'.
Re: Re: Appending to the ~beginning~ of a file.
by Vynce (Friar) on May 23, 2001 at 16:43 UTC

    i think what merlyn is trying to tell you is that you do it by rewriting the whole file... meaning, read it in, and write it back out with what you want in front of it.

    seek, if i have it right, affects only whence you read, not whither you write.

    (in other words, as some might say, "it can't be done" -- appending is inherently to the end of a file. sad, isn't it?)

    .
Re: Re: Appending to the embeginning/em of a file.
by Anonymous Monk on Jan 03, 2002 at 08:53 UTC
    you can look into This module which provides and easy OO way of working with files.