in reply to Passing values along with the called script

Say you have 2 values in the variables $foo and $bar. To run x.pl in another process:

$foo = 'whatever'; $bar = '42'; system $^X, 'x.pl', $foo, $bar; # run a new "perl script args"

to call x.pl from within the same perl interpreter:

$foo = 'whatever'; $bar = '42'; { local @ARGV = ($foo, $bar); do 'x.pl' };

In both variants $foo and $bar are in @ARGV in x.pl.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Passing values along with the called script
by Kashratul (Acolyte) on May 13, 2008 at 04:12 UTC
    thanks
Re^2: Passing values along with the called script
by Kashratul (Acolyte) on May 13, 2008 at 08:44 UTC
    Hi Monk,

    Your answer really did, what I wanted.

    Is it possible to return the output back into the calling script.

    Like .. taking the above script as example i.e. 'x.pl' and its two values => $foo, $bar

    Now I have another script lets call it 'y.pl'

    Now from 'y.pl' I am calling 'x.pl' and simultaneously passing these values.

    Then the output of 'x.pl' back to 'y.pl'. Something like 'return' does

    Thanks For any help