in reply to Non-buffered read from program

Fundamentally, the problem is that when the "whois" program (or most any other program) prints to its standard output using the standard C libraries, it does so in a heavily buffered fashion *unless* it's printing to a terminal, in which case its output is buffered line-by-line.

Since his standard output is connected to your standard input, and not to a terminal, it is heavily buffered.

Mucking around with $| will never help, since it's the other program's buffering, not your own, that's causing the problem.

The solution is to trick it into thinking it's talking to a terminal by using Expect.pm or Expect::Simple.

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

    Yes. Expect did solve this problem for me. Especially the raw_pty method.


    --
    Rohan

      Or if you don't want to use Expect when you're not planning on using all of its complexity, you could do something like: http://www.perlmonks.org/?node_id=393312 to put a pesudo-tty inbetween you and the command.