in reply to shelling out too much

requireing a script that isn't coded for that situation could override all kinds of data and subroutines in your calling code. also, require will only load a file once. if you are sure that it won't have any strange side-effects, you could probably do
@ARGV = '-h'; do 'myscript.pl';

However, since that will recompile the code each time, you will not gain optimum performance.

Your best strategy would be to put the shared code in a module and use that in both scripts. See perlmodlib.

Replies are listed 'Best First'.
Re^2: shelling out too much
by Fletch (Bishop) on Jun 27, 2005 at 12:33 UTC

    Or if you may still be using @ARGV in your own code you might want to localize that change.

    { local @ARGV = '-h'; do 'myscript.pl'; }

    --
    We're looking for people in ATL

Re^2: shelling out too much
by tlm (Prior) on Jun 27, 2005 at 12:32 UTC
    @ARGV = '-h'; do 'myscript.pl';

    Joost, I too thought of proposing something like this, but then I realized that if the OP is using backticks, he/she must be collecting the standard output of the child process, which neither do nor require would yield.

    the lowliest monk

      tlm, just because they're using backticks doesn't mean that they care about the output. It should mean that, but it doesn't necessarily mean that. I've seen many occurances, both here at perlmonks and at work, where people use backticks in void context as a short-cut to running system.

      Confusing the situation just a bit more is how the OP talks about possibly using require instead. Now, one possibility is that the OP doesn't need backticks, the other is that require wouldn't fit the bill, even if the "-h" parameter went away.