in reply to running string as perl script and pass into STDIN programatically
Do I have this straight?
From one running perl program, you want to invoke a second copy of perl running a second, pre-existing perl program, pass it a 3rd perl program, in the form of a single string, that it will then pass to a 3rd copy of perl to run.
And the problems you are having are:
Assuming $arg was 'x', this :open(my $fh,'|-', 'perl', '-', $arg); is equivalent to typing this at the command line:
perl - x
Which is obviously wrong. Try: open(my $fh,'|-', 'perl', "-$arg" );
From which instance of Perl?
You are invoking the second copy of perl with command line redirection, which means the first program should receive all stdout and stderr output from the second.
But any output from the third instance of perl will be going to its (virtual) console. Is it the STDERR output from this process you are having trouble capturing?
Because without trying it out, I could not even guess aa to what would happen to it on my OS; never mind on any other. At that point you have a hierarchy of processes like this:
<someshell> +-- perl +-- <someshell> (because of the command line redirection used +in backticks in the first program.) +-- perl +-- perl
And you are hoping the command line redirection in second level of shell, will capture both stdout & stderr output from the third level of perl.
One question: why? (Including, but not limited to:why not just embed the 10 lines of code in second perl program in the first? Wrapped over as a function if necessary.)
Another question: Could you post an example of the program that is being fed to the 3rd level perl?
Update:Another question: Why? :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: running string as perl script and pass into STDIN programatically
by gideondsouza (Pilgrim) on Feb 17, 2013 at 08:10 UTC | |
|
Re^2: running string as perl script and pass into STDIN programatically
by gideondsouza (Pilgrim) on Feb 17, 2013 at 08:41 UTC |