Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Quick Q about $|

Reply
Thread Tools

Quick Q about $|

 
 
Raj
Guest
Posts: n/a
 
      06-25-2003
Hi,

What does:

$|=1; select(STDOUT);

do? I understand that STDOUT is selected as the default handle, but what
about the bit preceding it?

Thanks,
Raj


 
Reply With Quote
 
 
 
 
bd
Guest
Posts: n/a
 
      06-25-2003
On Wed, 25 Jun 2003 15:37:49 +0100, Raj wrote:

> Hi,
>
> What does:
>
> $|=1; select(STDOUT);
>
> do? I understand that STDOUT is selected as the default handle, but what
> about the bit preceding it?


perldoc perlvar:
$| If set to nonzero, forces a flush right away and after every
write or print on the currently selected output channel.
Default is 0 (regardless of whether the channel is really
buffered by the system or not; $| tells you only whether you've
asked Perl explicitly to flush after each write). STDOUT will
typically be line buffered if output is to the terminal and
block buffered otherwise. Setting this variable is useful pri-
marily when you are outputting to a pipe or socket, such as
when you are running a Perl program under rsh and want to see
the output as it's happening. This has no effect on input
buffering. See "getc" in perlfunc for that. (Mnemonic: when
you want your pipes to be piping hot.)

--
Freenet distribution not available
Journalism is literature in a hurry.
-- Matthew Arnold

 
Reply With Quote
 
 
 
 
Matthew Weier O'Phinney
Guest
Posts: n/a
 
      06-25-2003
* Raj <>:
> What does:
>
> $|=1; select(STDOUT);
>
> do? I understand that STDOUT is selected as the default handle, but what
> about the bit preceding it?


$! = output autoflush. STDOUT is typically line buffered, which means
that there will often be a delay in seeing output if you're piping to
another process (CGI and rsh are two examples). By setting $| to a
non-zero value, you 'turn off' the buffering (actually, it flushes using
fflush(3) after each command that should be piped to STDOUT, usually
print or write).

--
Matthew Weier O'Phinney
http://weierophinney.net/matthew/
 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      06-25-2003
On Wed, 25 Jun 2003, wrote:
> Hi,
>
> What does:
>
> $|=1; select(STDOUT);
>
> do? I understand that STDOUT is selected as the default handle, but
> what about the bit preceding it?


Try "perldoc perlvar" to find the answer.

Ted
 
Reply With Quote
 
Eric J. Roode
Guest
Posts: n/a
 
      06-25-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matthew Weier O'Phinney <> wrote in
news:_NiKa.111694$:

> * Raj <>:
>> What does:
>>
>> $|=1; select(STDOUT);
>>
>> do? I understand that STDOUT is selected as the default handle, but
>> what about the bit preceding it?

>
> $! = output autoflush. STDOUT is typically line buffered, which means
> that there will often be a delay in seeing output if you're piping to
> another process (CGI and rsh are two examples). By setting $| to a
> non-zero value, you 'turn off' the buffering (actually, it flushes
> using fflush(3) after each command that should be piped to STDOUT,
> usually print or write).


Not STDOUT, but rather whatever filehandle was selected at the time $| was
set. The OP's example is sorta backward.

- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPvoaw2PeouIeTNHoEQJJBgCfeHXVj37NOyQVqOyK+MsuAt MY5qIAnA43
ta3Xmw0O8TBCxtYAsFaPi9sj
=ABLm
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding quick-release to a non-quick-release tripod head ste7esmith@hotmail.com Digital Photography 4 11-20-2006 03:19 PM
Quick question, hopefully quick answer. ~misfit~ NZ Computing 114 01-06-2005 01:36 PM
Quick Question Quick Answer JKop C++ 11 05-24-2004 09:46 PM
Quick Restore for a Compaq not so quick! Croos Bustamunky Computer Support 2 05-15-2004 04:17 AM
PanasonicBQ390 "quick" charger - How quick? Ol' Bab Digital Photography 1 01-17-2004 06:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57