You want the open on the outside of the loop.  You are using > on
the open, which basically gives you a new clean file each time.  You could
use >> for appending the data, but there is no reason to open the file
repeatedly.

Wags ;)

-----Original Message-----
From: Nandita Mullapudi [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 09, 2002 09:49
To: [EMAIL PROTECTED]
Subject: printing output to a file


hello list
i am trying to print the output of a parsing script to a file- the way it
is right now, the print commands are within a foreach loop, and it prints
to the screen. in order to get the entire output into a file, i'm using a
simple set of commands like so:

        foreach my $key (keys %alignments) {
    print "$key\nXXXXXXXXXXXX\n", $alignments{$key}, "\nXXXXXXXXXXX\n";

    open (OUT, '>outputfile.txt') or die "couldn't";
    print OUT "$key\nXXXXXXXXXXXX\n", $alignments{$key}, "\nXXXXXXXXXXX\n"
}

print $ending_annotation;
exit;

the output to the screen prints the entire output correctly, but when i
open the file output.txt i get only the last item in my output, not the
entire list..

any help appreciated..

many thanks
nandita.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to