in reply to lines written to stdout by a backtick command

When I run this:

use warnings; use strict; print `Perl noname2.pl`;

where noname2.pl contains:

use warnings; use strict; print "This is noname2.pl\n";

I get:

This is noname2.pl

which is what I would expect. What are you doing that is different?


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: lines written to stdout by a backtick command
by oceanic (Novice) on Aug 15, 2005 at 06:19 UTC
    For a start, thanks for your help :->

    I wasn't using "print `blah`;", so I tried that, but it hasn't made any difference.

    The script I am writing is called by another Perl script, which expects my script to produce lines from web server logs (so lots and lots of output). My script calls another script which actually reads the web server logs and organises them chronologically, then outputs the lines to stdout.

    What I need is for my script to "pass through" the stdout output from the script I call, and output it on it's own stdout.

    So at the moment, I construct a command (as an array) from a number of variables concatenated together (and when I print this command without executing it, it looks correct), and then I was calling it using "system()", but I realised after looking in the Perl docs that system() will only return the exit code of the command it called, so that is obviously no use to me.

    Then I found that calling a command using backticks apparently lets you see the output of the command, but I must still be doing something wrong, as it doesn't.

    Drew

Re^2: lines written to stdout by a backtick command
by oceanic (Novice) on Aug 15, 2005 at 05:58 UTC
    Hang on, let me try that ...

    Drew