On Jun 28, 2013 9:24 AM, "Shawn H Corey" <shawnhco...@gmail.com> wrote:
>
> On Fri, 28 Jun 2013 11:57:24 +0100
> Rob Dixon <rob.di...@gmx.com> wrote:
>
> > On 28/06/2013 02:32, Uri Guttman wrote:
> > >
> > > you don't need
> > > ever to set $| on stderr as it is not buffered like stdout is. and
> > > you rarely need to set it on stdout as any print with a \n will
> > > flush stdout.
> >
> > That isn't true.
> >
> > Perl will buffer STDOUT up to 8KB regardless of whether a newline has
> > been printed, unless `autoflush` has been enabled when it will flush
> > after every print `statement`.
> >
> > Rob
> >
> >
>
> I don't think that's correct. If connected to a terminal, both STDOUT
> and STDERR will buffer until a newline and then flush. If connected to
> anything else, then they will use the full buffer.

It's internal to perl and not an fd or any other Unix thing. This is pretty
well documented outside of perldoc (perl monks and blogs).

>
> One should not be worried about setting autoflush since in most cases,
> Perl will do the correct thing. It's only when you are manipulating the
> terminal's cursor directly would you need to set it.

I've only done this once and since I can't recall where, I don't know
whether I was being stupid or not. You're *generally* correct. Though, the
'correct thing is to buffer and give a speed improvement over not
buffering.

Reply via email to