ckyang74 has asked for the wisdom of the Perl Monks concerning the following question:

I want to run a command xyz with Perl. xyz requires several input, basically like this:

name:
address:
tel:

I want to capture the STDOUTed strings (eg: "name:") in variables, but I do not want to use back-tick (I still want to see them on the screen).

Basically what I want is a Expect script like code, so that I can use it for repetitive input of names, addresses, etc. Could somebody give me some idea? Thanks.

  • Comment on interactively catching STDOUT/STDERR messages

Replies are listed 'Best First'.
Re: interactively catching STDOUT/STDERR messages
by Tanktalus (Canon) on Nov 11, 2005 at 03:50 UTC

    If you're looking for Expect like behaviour, have you tried the Expect module? It may already do exactly what you want, exactly the way you're thinking of the problem.

Re: interactively catching STDOUT/STDERR messages
by blazar (Canon) on Nov 11, 2005 at 09:51 UTC
    I'm not really sure, but since you mention STDERR in the subject, you may be interested in IPC::Open2 or IPC::Open3. If you're just interested in STDOUT, I'd use an explicit open, and then I'd print to "see them on the screen".