Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a script where data is gotten from a website through LWP::Simple, gets formatted, and then written to a filehandle. My problem is that more than one set of information may be written during the script, and all thigns written must be availiable at the end of the script

this wouldn't be a problem, except each time I write to the filehandle, it overwrites what is already there.

how do I tell perl to append rather than overwrite?

20050102 Edit by ysth: change title from "append", add p tags

Replies are listed 'Best First'.
Re: append
by tachyon (Chancellor) on Jan 03, 2005 at 00:11 UTC

    You want >> not >

    open F, ">$file" or die "Can't create/overwite $file $!\n"; open F, ">>$file" or die "Can't append to $file $!\n";

    cheers

    tachyon

Re: append
by Mr. Muskrat (Canon) on Jan 02, 2005 at 23:58 UTC
Re: append text to existing file
by Cody Pendant (Prior) on Jan 03, 2005 at 04:20 UTC
    Your problem may just be that you're doing
    for(something){ open file get info write info to file close file }
    When you could do
    open file for(something){ get info write info to file } close file


    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
    =~y~b-v~a-z~s; print