|| at Jul 10, 2001 at 6:36 pm
--- "P. Schaub" wrote:
I am calling a perl script within another perl script.
Have you looked into require() and do()?
What is the best way to pass arguments to the second one ?
Depends on what you want, what it does, and how it's written.
Is it possible to pass arrays and hashs (or at least refs) ?
Anything's possible, but not usually the way you'd like.
If the script is written for it, you could require() it and then call
it's functions from your own code. Other than that, I don't think
you're gonna get what you want here.
So far I am calling the second script like
@result=`script2.pl $arg1 $arg2 $arg3`
but I guess this is quite ugly.
Is it working? Does it beat your machine into whimpering submission?
If the answers are 'yes' and 'no', then it might be better than trying
to rewrite the code in script2.pl; on the other hand, if the code in
script2 is very useful then it might be worth a few hours to wrap it up
in a module. Then you could rewrite script2 with a few lines, and
include the same functionality in script1 and script53 with just a few
lines....and then you probably could share any data in the program,
like a hash ref. =o)