Dave Kettmann wrote:
> Hello,
> 
> I have built a script that has 2 environment variables passed to it
> and it will take that data and return a value. This script works
> fine, but there are many possibilites that can be passed to it. I
> want to build a test case of sorts to pass to this script. In
> 'meta-code' this is what I would like to do:    
> 
> @from_numbers = qw( "6364421234", "6364421234", "3143221234", "3143221234"
); 
> @to_numbers = qw( "4225678", "6364425678", "3212222", "3143212222"); 

Erm, you're not using qw() properly.

> 
> while (@from_numbers) {
> 
> set environment variable to from_number
> set additional variable to to_number
> run script
> 
> }
> 
> My main question: Is there a better way to run the other perl script
> other than running an exec()? I am trying to keep processor usage
> down to a minimum and I know that the exec() function opens up a
> shell (which takes both time, memory, and processor). I dont know if
> perl has a 'better' way to handle running another perl script.

You wouldn't use exec(), since that replaces your currently running process
with another. You would use system() or backticks. None of these use a shell
unless
you include shell meta-characters.

There's no reason to avoid these calls, IMO. This is the most straightfoward
way to approach it.

I would suggest something like this:

   while (<DATA>) {
       ($ENV{VAR1}, $ENV{VAR2}) = split;
       system('/path/to/myscript.pl');
   }

   __DATA__
   6364421234  4225678
   6364421234  6364425678
   ... and so on

HTH

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to