in reply to Non-buffered read from program

Try this code:
open FH, "whois x.x.x.x 2>&1 |"; my $ofh =select(FH); $|=1; select($ofh); #changed while (<FH>) { print; } close FH;
On my environment ,this works good. Hope this helps,

Replies are listed 'Best First'.
Re^2: Non-buffered read from program
by arc_of_descent (Hermit) on Dec 30, 2005 at 14:08 UTC

    Doesn't seem to work on mine. IO::Handle too does not help.

    use strict; use warnings; use IO::Handle; open my $WHOIS, "jwhois x.x.x.x 2>&1 |"; my $io = IO::Handle->new; $io->fdopen($WHOIS, "r"); $io->blocking(0); print $io->getline; $io->close;

    I don't get any output, if the server is unavailable.


    --
    Rohan

      Do you mean to use $io->autoflush(1) ? Try this code:
      use strict; use warnings; use IO::Handle; open my $WHOIS, "whois x.x.x.x 2>&1 |"; my $io = IO::Handle->new; $io->fdopen($WHOIS, "r"); $io->autoflush(1); while(my $line = $io->getline){ print $line; } $io->close;
      This is working fine on my environment.