Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: simple regex question

by Marshall (Canon)
on Nov 27, 2010 at 04:56 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-19 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found