#----------------------------- |
$old_fh = select (OUTPUT_HANDLE); |
$| = 1; |
select ( $old_fh ); |
#----------------------------- |
use IO::Handle; |
OUTPUT_HANDLE->autoflush(1); |
#----------------------------- |
# download the following standalone program |
#!/usr/bin/perl -w |
# seeme - demo stdio output buffering |
$| = ( @ARGV > 0); # command buffered if arguments given |
print "Now you don't see it..." ; |
sleep 2; |
print "now you do\n" ; |
#----------------------------- |
select (( select (OUTPUT_HANDLE), $| = 1)[0]); |
#----------------------------- |
use FileHandle; |
STDERR->autoflush; # already unbuffered in stdio |
$filehandle ->autoflush(0); |
#----------------------------- |
use IO::Handle; |
# assume REMOTE_CONN is an interactive socket handle, |
# but DISK_FILE is a handle to a regular file. |
autoflush REMOTE_CONN 1; # unbuffer for clarity |
autoflush DISK_FILE 0; # buffer this for speed |
#----------------------------- |
# download the following standalone program |
#!/usr/bin/perl |
# getpcomidx - fetch www.perl.com's index.html document |
use IO:: Socket ; |
$sock = new IO:: Socket ::INET (PeerAddr => 'www.perl.com' , |
PeerPort => 'http(80)' ); |
die "Couldn't create socket: $@" unless $sock ; |
# the library doesn't support $! setting; it uses $@ |
$sock ->autoflush(1); |
# Mac *must* have \015\012\015\012 instead of \n\n here. |
# It's a good idea for others, too, as that's the spec, |
# but implementations are encouraged to accept "\cJ\cJ" too, |
# and as far as we're seen, they do. |
$sock -> print ( "GET /index.html http/1.1\n\n" ); |
$document = join ( '' , $sock ->getlines()); |
print "DOC IS: $document\n" ; |
#----------------------------- |