in reply to what is the meaning of $| in perl?
Now that you know what $| is, I suggest you don't use it! For Perl 5.8+, instead of your global LOGFILE file handle and:
it is preferable to use a lexical file handle ($logfile say) and then simply:select(LOGFILE); $| = 1; select(STDOUT);
use IO::Handle; # not needed for Perl 5.14+ # ... $logfile->autoflush();
Note that for Perl 5.14+ you don't need use IO::Handle because:
Before Perl 5.14, lexical filehandles were objects of the IO::Handle class, but you had to load IO::Handle explicitly before you could call methods on them. As of Perl 5.14, lexical filehandles are instances of IO::File and Perl loads IO::File for you.
Extra References Added Later
From On Interfaces and APIs:
Lexical file handles are, for me, the most important feature introduced in Perl 5.6. Those evil old global file handles spawned a host of unfortunate idioms, such as:
In terms of a clear and simple interface to perform a simple task (set autoflush on a file handle), it doesn't get much worse than that, a compelling illustration of why keeping state in global variables is just plain evil ...select((select($fh), $|=1)[0]);
See also:
PM References
Unicode/UTF-8
|
---|