I have the following Perl code:
STDOUT->autoflush(1);
foreach(...)
{
...
foreach(...)
{
print("Processing $folder");
$|=1;
process($folder);
}
...
}
但是print语句只在循环的第一次迭代中起作用,之后不再打印任何内容。有什么想法吗?
编辑:我已经找到了原因,并在答案中添加了它。
解决方案如下:
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...