http://www.perlmonks.org?node_id=873965


in reply to Re^2: simple regex question
in thread simple regex question

There are some caveats with buffering on STDOUT. The behavior changes if Perl figures that STDOUT has been redirected to something not a physical console. Consider:
#!/usr/bin/perl -w use strict; for (0..200) { print "$_ buffered xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"; print STDERR "$_ unbuffered \n"; }
When run from the command line, STDOUT is indeed unbuffered and you see alternating buffered/unbuffered statements. However for example if I run this in Textpad (my editor on Windows - I think similar to Notepad++) and have it capture the output, STDOUT is buffered. And the first buffered line is output after about 88 lines. I conclude that on my Windows system the buffer is about 8KB. So it depends upon where STDOUT is directed to.