Rob Dixon wrote at Sat, 29 Mar 2003 12:59:22 +0000:

>>        $|      If set to nonzero, forces a flush right away and
>> [ ... ]
>> 
> I'll throw in my usual thing here: that it's better to use
> 
>     use IO::Handle;    # a standard module
> 
>     autoflush STDOUT;

Looks really good :-)

>     use IO::Handle;
>     autoflush STDOUT;
>     autoflush STDERR;
> 
>     print STDERR "STDERR\n";
>     print STDOUT "STDOUT\n";
> 
> so that the output you see is in the order it happens. Without the
> autoflush calls ( or even with just $| = 1 ) the above program will
> output
> 
>     STDOUT
>     STDERR

The following snippet:
#!/usr/bin/perl

$| = 1;
print STDERR "STDERR\n";
print STDOUT "STDOUT\n";

$| = 0;
print STDERR "STDERR\n";
print STDOUT "STDOUT\n";

has the output

STDERR
STDOUT
STDERR
STDOUT

and not
STDOUT
STDERR
...


Cheerio,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to