Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: simple regex question

by Marshall (Abbot)
on Nov 27, 2010 at 04:56 UTC ( #873965=note: print w/replies, xml ) Need Help??

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.

Replies are listed 'Best First'.
Re^4: simple regex question
by JavaFan (Canon) on Nov 27, 2010 at 11:10 UTC
    I'm fully aware of that, and that's why I wrote by default. It's completely irrelevant for the program I was replying to, as it wasn't writing to different filehandles, and then outside of the program merging them again. It was writing to STDOUT, and nothing else. If it was being redirected to a file, you don't need to unbuffer.

    But my beef wasn't so much about the unbuffering. It was about the idiom that should never have been cargo culted into widespread use.

    Yes, and I know who to blame.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873965]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-10-21 07:41 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (119 votes). Check out past polls.