in reply to what is the meaning of $| in perl?
Now that you know what $| is,
I suggest you don't use it.
Instead of your global LOGFILE file handle and:
it is preferable to use a lexical file handle
($logfile say) for your log file and then simply:
select(LOGFILE); $| = 1;
With recent Perls (5.8+), there's no need anymore to confusingly change the (global) default destination
for print statements via the one-argument form of select -- for
more details, see Perl Best Practices, chapter 10 and
Perl tip: Buffering and IO::Handle
(for Perl 5.14+ you
don't need use IO::Handle).