If you're able to write to STDOUT but not to a file, it sounds like the way you're opening (or, not opening in this case) a file handle.For instance:open(FILE,">/tmp/log.txt");...print FILE "something meaningful\n";...close(FILE);... writes to a file. Even if you have the 1st and 3rd statement above, you might still be writing to STDOUT if you forget to print to the file handle.Dave
if (open(OUT, '>', $fname)){ #... success ...}else { #... error ...}
open(OUT, '>', $fname) || die(" '$fname' ($!)");#... success ...
I have a Perl program which goes through about 1000 branches and read one specific DCR from each branch. It then reads the metadata on the DCR and writes that info in to a text file. Each line represents a DCR from every branch. I get about 1000 lines every time I run this script.The problem is that, the script works fine sometimes with correct data and sometimes fails by printing the blank values for some of the metadata fields. When I go and double check the DCRS the metadata values do exist. I put debug print statements and it prints on the console but not in to the text file!I am wondering if this issue has anything to do with buffering or memory. Does anyone have idea about it?