in reply to writing to a file

Sure it's possible:
open FH, "+< $filename" or die $!; seek FH, 0, 0 or die $!; print FH "sm.th."; # printing to the first line


Replies are listed 'Best First'.
Re^2: writing to a file
by holli (Abbot) on Jul 01, 2005 at 09:57 UTC
    That reminds me of the user who asked the admin for more disk space.

    user: I need more disk space
    admin (types): You have 20 MB free
    user: Oh great, then I have 40 MB all in all now.
    admin: err, no.


    holli, /regexed monk/
Re^2: writing to a file
by anonymized user 468275 (Curate) on Jul 01, 2005 at 10:14 UTC
    That would overwrite from the beginning rather than append. Unless the file is small enough to read into an array, unshift the new first line in, do the same zero-seek and then print it back in this overwrite mode, a much more complex solution would be required using read aheads, rewriting the previous buffer and iterating through the whole file.

    One world, one people