Nice example! I prefer autoflush because the intent is much clearer than messing with the $| global variable.
As an aside, it's a shame Perl was originally released with so many evil global variables because by the time lexical file handles made it into Perl 5.6 a host of unfortunate idioms were in common use, such as:
select((select(FH), $|=1)[0]);
Of course, such old coding horrors like this can be expressed more clearly nowadays with a lexical file handle (see also):
use IO::Handle; # update: not needed for Perl 5.14+ # ... $fh->autoflush();
For more examples of historic interface design boo-boos, see the Some Examples of Interface Mistakes section at: On Interfaces and APIs
In reply to Re^2: The print is output later after die
by eyepopslikeamosquito
in thread The print is output later after die
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |