Hi,
I have the following Perl code:
STDOUT->autoflush(1);
foreach(...)
{
...
foreach(...)
{
print("Processing $folder");
$|=1;
process($folder);
}
...
}
but the print statement works only in the first iteration of the loop and does not print anything after that. Any idea why?
EDIT: I found the reason and have added it in the answer also. The solution was:
I added the following line inside the loop and it worked:
select STDOUT;
I think the code in process() function should have been modifying the default output buffer. It was a code written by somebody else!
I am not sure if this is a problem with Perl which allows this or the developer who did not change it back to the default.
The final code looked like this:
foreach(...) { ... foreach(...) { select STDOUT; print("Processing $folder"); $|=1; process($folder); } ... }
Thanks all...