##
use IO::Handle; # thousands of lines just for autoflush :-(
##
##
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