Perl threads - capturing value returned from sub
- From: "Eric" <ecarlson@xxxxxxxxxx>
- Date: 26 Feb 2007 17:03:21 -0800
Hello,
I am using Perl threads to launch multiple executions of a command in
parallel. The code to do this is:
foreach my $Machine ($self->Machines) {
my $thr = threads->new(\&doPowerAction, $Machine);
}
foreach my $t (threads->list()) {
$t->join;
}
The sub referenced is:
sub doPowerAction
{
my $machine = shift;
my $runScript = `power.exp $machine`;
if ($runScript =~ m/SUCCESS/) {
return "SUCCESS";
} elsif ($runScript =~ m/FAILURE/) {
return "FAILURE";
} else {
return "INTERNAL_ERROR";
}
}
The problem is that I don't seem to be able to figure out how to
capture the return value in the calling routine. Does anyone know how
to do this?
Thanks in advance to all that respond.
Eric
.
- Follow-Ups:
- Re: Perl threads - capturing value returned from sub
- From: Eric
- Re: Perl threads - capturing value returned from sub
- From: A. Sinan Unur
- Re: Perl threads - capturing value returned from sub
- Prev by Date: Re: carriage returns in HERE statements
- Next by Date: Re: DocumentHTML ?
- Previous by thread: DocumentHTML ?
- Next by thread: Re: Perl threads - capturing value returned from sub
- Index(es):
Relevant Pages
|