Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$¦ = 1;

Status
Not open for further replies.

DaRedMonkey

IS-IT--Management
Aug 23, 2002
17
US

What exactly is this line for? Is it to allow you to work with data in paragraph mode?

$| = 1;

 
That's a toggle for flushing the buffer.

Most useful in command line perl scripts, as it dumps the output to the console without waiting for the buffer to fill

Also known as $OUTPUT_AUTOFLUSH

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
All of perl's odder variables are documented in perldoc.com/perl5.8.0/pod/perlvar.html along with the helpful longhand names you can use for them if you use the [tt]Use English;[/tt] pragma.

Yours,


fish

"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilkes
 
so what must we use under win32 if we want to flush the buffer now that we know that $| is not working?
 
Nik,

Search this forum for "flush buffer", and you'll find some relevant results

HTH
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
I'm not sure what you folks are referring to, but $| = 1 has always auto-flushed for me in windows. It was a little more than six months ago before I used it, but it's worked every time.

If it makes any difference: ActiveState's Perl 5.8.0 / Windows 2000

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
icrf, are you sure you've used it in a context where the effects of $|=1 could truly be seen. The example I usually throw at people is to try and stream a 'tail -f $file' command through CGI. In every Win32 environment I've used it hangs.

Barbie
Leader of Birmingham Perl Mongers
 
I can say I've seen it make a difference. Example at the command line:
Code:
use strict;
use warnings;

$| = 1;

print "a";
sleep 1;
print "b";
sleep 1;
print "\n";
With $| true, it spits an 'a', waits a second, spits a 'b', waits a second, then a newline. Without $| true, it waits two seconds, then prints "ab\n". I assumed that was the purpose of $|. Did I miss something?

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
ircf i have tried the example you provided about the $I and i notice that the script it waits two seconds, then prints "ab\n" no matter if i use or if i dont use the $I (Autoflash). it doesnt make any difference if i put it or not! I was testing it on XP.

if some other guy tested it let us know the result.
 
Nik,

It's $| not $I

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
yes $| is what i wantes to mention and by mistake i have typed $I. i have now just retried it and i still got the same results.....

any idea else how we can autoflash in windows enviroment??
 
Anyone else here running Perl in Windows? I'm curious if I've got some strange luck or what. Mention what Windows and Perl versions you're running and whether or not $| makes any difference.

I really can't explain it. Is there a Perl resource somewheres that might cover/mention something like this?

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
ASPN && (Win98 || WinXP)
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
what do you mean PaulTEG?

ircf if you find anything pls let me know ok, or just post something!

Thanks!
 
$|=1 flushes the output for me, perl 5.8.0 under activestate, win2K (I'd imagine XP would react the same?)
 
Hello All,

Perl 5.8.0 from activstate. Tested the autoflush with :

win98 (1st ed and 2nd ed),
win2k (prof and workstation),
win2k server,
win2003 server,
winxp (prof only)

and works on all of them

Could be config issue under WinXP.

Recommendation (my opinion only): WinXp is a waste of time.

I looked at microsoft sales stats and WinXP is the crapiest and the lowest seller ever. (remember its the first 64-bit based system they ever made, not bug-free).
 
POF (point of fact)

Not the first 63-bitOS they've developed, there wuz a 54 bit version of NT that crapped out under drag'n'drop


(*the Itanium didn't just appear ...., did it ...)
E&O excepted, expeceted, accepted ... whatever ...

Let's not get excited ...

let's bear down on a common test plate, and compare common results.

Play ball ...

--Paul




It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
TheGenius22:

I don't know about what you just said... for one, I thought windows xp was simply an enhanced win2k, and you had to buy the 64 bit version to to operate as 64 bit?

And also I sincerely believe that the consensus is that the award for microsoft's "crapiest and lowest seller ever" goes to win ME, which broke more things than it fixed...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top