Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

can anyone help with this?

Replies are listed 'Best First'.
Re: what does '$| = 1' mean?
by DamnDirtyApe (Curate) on Aug 11, 2002 at 15:31 UTC

    Suffering from Buffering? is a great article that describes why $| = 1 can be important.


    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche
Re: what does '$| = 1' mean?
by fruiture (Curate) on Aug 11, 2002 at 10:58 UTC

    Well, this sets the scalar variable '$|' to 1. $| is a special variable that controls autoflushing of the currently select()ed handle. See perlvar for details.

    --
    http://fruiture.de
Re: what does '$| = 1' mean?
by virtualsue (Vicar) on Aug 11, 2002 at 12:39 UTC
    As already suggested, you can read perldoc perlvar for a bit of information on $|. In addition, you can find some more detailed discussion on the output autoflush setting at theOfficial Perl FAQ, section 5
Re: what does '$| = 1' mean?
by zentara (Cardinal) on Aug 11, 2002 at 15:13 UTC
    On a practical level for beginners, it means:
    Dont' buffer STDOUT.
    Normally when your program outputs data, it waits
    for 2k worth of data to accumulate, before printing.
    When you set $|=1;  the program will output any data
    immediately, without buffering. This is very useful in cgi. 
    
    For a little example of what this means in a real program:
    #!/usr/bin/perl #without a newline, it won't print #until the buffer is 2k #$|=1; # try it with and without this line :-) while (1){ print 'aaaaaa'; select(undef,undef,undef,.03); }

      On a practical level for beginners, it means:
      Don't buffer STDOUT.

      Well, yeeeessss. Buffering is still happening. It's just that setting $| to true asks for the buffer to be emptied after each output command (print, printf, etc) rather than wait until a newline or a full buffer is encountered.

Re: what does '$| = 1' mean?
by YuckFoo (Abbot) on Aug 11, 2002 at 11:04 UTC
    This and other predefined variables are explained on the perlvar page. The perldoc command will get you there as well. Try 'perldoc perlvar' from your command line.