In larger scripts, I simultaneously handle that and the clarity issue by writing code like this001 use IO::Handle; 002 STDOUT->autoflush;
I got kinda turned off of IO->Handle when I read this comment in the pod
use IO::Handle; # thousands of lines just for autoflush :-(
When I read the authors name, it strengthened the feeling.
Update: To clarify, the author to which I referred was the author of the comment I quoted above--from the pod of perlipc not IO->Handle--Tom Christiansen, who comments are to be valued.
I have absolutely nothing against Graham Barr (the author of IO::Handle), nor even much against that module.
My only reservation was of the practice of using IO->Handle only for the purposes of turning on autoflush.
If $|=1; $|=0; is deemed to cryptic, you could use something like:
sub autoflush (*$) { # Set the state of autoflush for # the handle supplied as $_[0] # to the boolean state supplied as $_[1] select( do{ my $old = select( $_[0] ); $| = $_[1]; $old; } ) } ... autoflush( STDOUT, 1 ); # autoflush on ... autoflush( STDOUT, 0 ); # autoflush off
In reply to Re: Re: Re: Perl Idioms Explained - $|++
by BrowserUk
in thread Perl Idioms Explained - $|++
by broquaint
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |