Hi I have looked at this forum
I am trying to make a system call to a perl program from another perl program. The program which is being called takes two numbers as its parameters. The first of which is a number read in from a text file ie 1,2,3 etc and then the second number is a number which is less than or equal to the first number. I have a while loop that evaluates each line in the text file before moving onto the next one.
The call should look like this
perl prog.pl 2 1
but what i get is
Perl prog.pl 2
1
unknown comand 1
My code is as follows. I did try both single quotes and double quotes for the system call.
I am trying to make a system call to a perl program from another perl program. The program which is being called takes two numbers as its parameters. The first of which is a number read in from a text file ie 1,2,3 etc and then the second number is a number which is less than or equal to the first number. I have a while loop that evaluates each line in the text file before moving onto the next one.
The call should look like this
perl prog.pl 2 1
but what i get is
Perl prog.pl 2
1
unknown comand 1
My code is as follows. I did try both single quotes and double quotes for the system call.
Code:
#!/usr/bin/perl5.8.5
use strict();
open(FILE, "numbers.pid") or die ("unable to find file\n"); # opens the geturl 'pid file'
@instancearray = <FILE>; # stores the values into an array called
close(FILE);
my $i =0; # accesses data in array
my $a = 1; # needed as secondary value for call to get url
foreach $line (@instancearray)
{
while ($a<=$instancearray[$i])
{
# print "test\n";
print "restarting instance number $instancearray[$i]$a \n";
system ("perl prog.pl $instancearray[$i] $a")==0;
$a = $a+1;
}
$i++;
$a = 1;
}
open(OUT,"numbers.pid") or die ("unable to find output file\n");#
$instancearray = ();
foreach $number (@instancearray)#
{#
print OUT "$number\n";#
}#