Dave Kettmann wrote:
Hello,

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.

You should probably search for "test" on http://search.cpan.org.

http://search.cpan.org/search?m=module&q=test&s=1&n=100


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");

If you had warnings enabled then perl would have warned you about that:

$ perl -le'use warnings; my @x = qw( "1", "2", "3" ); print for @x'
Possible attempt to separate words with commas at -e line 1.
"1",
"2",
"3"

So what you want is either:

my @from_numbers = qw( 6364421234 6364421234 3143221234 3143221234 );
my @to_numbers   = qw(    4225678 6364425678    3212222 3143212222 );

Or:

my @from_numbers = ( 6364421234, 6364421234, 3143221234, 3143221234 );
my @to_numbers   = (    4225678, 6364425678,    3212222, 3143212222 );

Or even:

my @from_numbers = ( '6364421234', '6364421234', '3143221234', '3143221234' );
my @to_numbers   = (    '4225678', '6364425678',    '3212222', '3143212222' );


And of course, you should probably be using strict as well.


while (@from_numbers) {

set environment variable to from_number
set additional variable to to_number
run script

}

From your pseudo code description, you may want to use an array of arrays or array of hashes instead, if you want to keep the corresponding from and to numbers together.



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).

It only uses a shell in certain circumstances:

perldoc -f exec
[snip]

            If there is more than one argument in LIST, or if LIST is an array
            with more than one value, calls execvp(3) with the arguments in
            LIST.  If there is only one scalar argument or an array with one
            element in it, the argument is checked for shell metacharacters,
            and if there are any, the entire argument is passed to the
            system's command shell for parsing (this is "/bin/sh -c" on Unix
            platforms, but varies on other platforms).  If there are no shell
            metacharacters in the argument, it is split into words and passed
            directly to "execvp", which is more efficient.



John
--
use Perl;
program
fulfillment

--
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