I have the following Perl code:
STDOUT->autoflush(1);
foreach(...)
{
...
foreach(...)
{
print("Processing $folder");
$|=1;
process($folder);
}
...
}
but the print statement only works in the first iteration of the loop and after that prints nothing. Any idea why?
EDIT: I found the reason and added it in response. The solution was:
I added the following line inside and it worked:
select STDOUT;
I think the code in process () function should have changed the default output buffer. It was written by someone else!
I'm not sure if this is a problem with Perl, which allows it, or a developer who has not changed it by default.
The last code looked like this:
foreach(...)
{
...
foreach(...)
{
select STDOUT;
print("Processing $folder");
$|=1;
process($folder);
}
...
}
Thanks everyone ...
source
share