Brandon McCaig wrote:
On Thu, Mar 07, 2013 at 10:21:40AM +0100, WFB wrote:
Hi, List,
Hello,
To test our software I use perl to start it several times. My
perl script gather some information and start then the program
with different parameters.
It works very well, but I have a problem with the return values
of our program. This return codes are all in an area from 55000
to 60000. I use open to invoke our program and print the
output. Finally I use the $? variable and print the error code
in case of an error.
sub start_test_runner {
my ($tr = shift, $tr_params) = @_;
I don't see a need for shift here. You can just assign the
arguments array to your list of parameters.
my ($tr, $tr_params) = @_;
my $pid = open(my $trexe, "$tr \"$tr_params\" |") or die "Could not start
TestRunner. $!\n";
Instead of escaping the double-quotes consider using the qq//
operator instead. You should also prefer the 3-argument open.
my $pid = open(my $trexe, '-|', qq($tr "$tr_params") or
die "Could not start TestRunner. $!";
Or, instead of the three argument open, use the list option and you
won't need quotes:
my $pid = open my $trexe, '-|', $tr, $tr_params
or die "Could not start TestRunner. $!";
Also, be sure to close the pipe correctly:
close $trexe or warn $! ? "Error closing $tr pipe: $!"
: "Exit status $? from $tr";
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/