in reply to Re: Re: Re: Problem dup'ing STDOUT
in thread Problem dup'ing STDOUT

Not quite. According to my copy of the Camel Book, under system() it says:
To capture the output from a command, use backticks or qx//."

Which is what I had been doing.


"Ex libris un peut de tout"

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Problem dup'ing STDOUT
by Joost (Canon) on Nov 26, 2003 at 18:05 UTC
    No, you dumped the output away:

    From perlop / qx:

    The collected standard output of the command is returned; standard error is unaffected. In scalar context, it comes back as a single (potentially multi-line) string, or undef if the command failed. In list context, returns a list of lines (however you've defined lines with $/ or $INPUT_RECORD_SEPARATOR), or an empty list if the command failed.
    That means the output of qx!command! will not be send to STDOUT, but returned from the qx call; you cannot capture it from outside the perl program executing qx!command!. You need system("command") which will let all output through to STDOUT (and STDERR) so you can capture it later.

    You COULD also do print qx!command! but I don't really see the point :-)

    Joost.

    -- #!/usr/bin/perl -w use strict;$;= ";Jtunsitr pa;ngo;t1h\$e;r. )p.e(r;ls ;h;a;c.k^e;rs ";$_=$;;do{$..=chop}while(chop);$_=$;;eval$.;
      OK, I think I need to take a break from this and come back to it fresh after the holiday. Thanks for the input.


      "Ex libris un peut de tout"