Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: simple regex question

by Marshall (Prior)
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.


Comment on Re^3: simple regex question
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-08-01 08:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls