hi,
I would like to capture all the output in my perl program during execution. I 
have code that basically opens and closes an output file multiple times just to 
write the output. Because I have system calls between lines of code, I have to 
close the file in order to capture the output from the system calls and write 
it to the same file (in this case /tmp/tmp.log) . 

Not an elegant code. Is there a better way of rewriting the code?  

Appreciate any suggestions/comments.

sample code:

open(OUTF, ">>/tmp/tmp.log" ) || die "Cannot write file";
if ($i==10) {
        print OUTF "i=10\n\n";
} else {
        print OUTF "i!=10\n\n";
}
close OUTF;
system ("ls nofile.txt 2>> /tmp/tmp.log");
...
<some operations>
...
open (OUTF, ">>/tmp/tmp.log" ) || die "Cannot write file";
if ($j==20) {
        print OUTF "j=20\n\n";
} else {
        print OUTF "j!=20\n\n";
}
close OUTF;

thanks.

Geraldine

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to