in reply to Add a line to the end of a file

It shouldn't load the file into memory. There is no reason for it.

I also don't think that there is a better way to do it.

But this ain't a perl question,

Replies are listed 'Best First'.
Re: Re: Add a line to the end of a file
by tachyon (Chancellor) on Feb 17, 2004 at 23:08 UTC

    I also don't think that there is a better way to do it.

    How about just:

    echo 'stuff' >> file.txt

    This will be much faster and use buckets less memory than firing up a full blown perl interpretter. Works on Win32 or *nix. It's shorter. Better? Depends what you need.... As always YMMV.

    C:\>echo Hello World! > better C:\>date /T >> better C:\>type better Hello World! Tue 17/02/2004 C:\>

    cheers

    tachyon

      Did he say the appending to the log is the only thing his script does? Nope, he didn't. So as usualy I'd assume that this logging is just a part of a more complex perl script. An echo wouldn't be of much use, don't you aggree?

      Update (at -1): Yes! Come on! Downvote me! Hey! What's wrong with this! Please explain...
Re: Re: Add a line to the end of a file
by hardburn (Abbot) on Feb 17, 2004 at 22:25 UTC

    Actually, it is a perl question, at least in part, though it's not really a Perl question. (See my other reply).

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated