From: efoss on 2 Mar 2010 13:44 I want to be certain that a print statement is immediately executed. Googling around led me to use "$| = 1". Is this correct? Here is an example of how I'm using it: my $test; $| = 1; $test = 3; print "test is $test\n"; Thanks. Eric
From: J�rgen Exner on 2 Mar 2010 13:50 "efoss(a)fhcrc.org" <efoss(a)fhcrc.org> wrote: >I want to be certain that a print statement is immediately executed. >Googling around led me to use "$| = 1". Is this correct? Here is an >example of how I'm using it: > >$| = 1; >$test = 3; >print "test is $test\n"; Yes, that is the correct use of $|. However it only tells perl to not buffer the output and has no impact on whatever buffereing your OS or terminal server or server-client protocol (if applicable) decides to do. jue
From: Ben Morrow on 2 Mar 2010 14:01 Quoth "efoss(a)fhcrc.org" <efoss(a)fhcrc.org>: > I want to be certain that a print statement is immediately executed. > Googling around led me to use "$| = 1". Is this correct? Here is an > example of how I'm using it: perldoc perlvar Ben
From: Uri Guttman on 2 Mar 2010 14:29 >>>>> "JE" == J�rgen Exner <jurgenex(a)hotmail.com> writes: JE> "efoss(a)fhcrc.org" <efoss(a)fhcrc.org> wrote: >> I want to be certain that a print statement is immediately executed. >> Googling around led me to use "$| = 1". Is this correct? Here is an >> example of how I'm using it: >> >> $| = 1; >> $test = 3; >> print "test is $test\n"; JE> Yes, that is the correct use of $|. actually that never uses $| ! the print string ends in newline so it will always be flushed to stdout. $| is meant for when you print text without a newline (say a prompt or partial output or to a socket). also since the program ends there, you also won't see any difference with setting $| or not as stdout gets flushed then as well. you need to print a string without a newline and then sleep or wait for input or something to see the difference. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Willem on 2 Mar 2010 15:41
Uri Guttman wrote: ) actually that never uses $| ! the print string ends in newline so it ) will always be flushed to stdout. $| is meant for when you print text ) without a newline (say a prompt or partial output or to a socket). ) ) also since the program ends there, you also won't see any difference ) with setting $| or not as stdout gets flushed then as well. you need to ) print a string without a newline and then sleep or wait for input or ) something to see the difference. AFAIK, not true if stdout is redirected to a file. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT |