Perl threads - capturing value returned from sub



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

.



Relevant Pages

  • Re: Perl threads - capturing value returned from sub
    ... I am using Perl threads to launch multiple executions of a command in ... foreach my $Machine { ...
    (comp.lang.perl.misc)
  • Re: Import Members into a DL from .csv file
    ... Please do not send email directly to this alias. ... foreach loop, and invoke add-distributiongroupmember within the foreach. ... Finally this is the command i am running the below command to import this ... roperties do not match any of the parameters that take pipeline input. ...
    (microsoft.public.exchange.admin)
  • Re: Help: Process many files at the same time
    ... If you want to read all files on the command line, one after the other, ... Even with the useless foreach loop around the ... After this first iteration, @ARGV is empty, so there ...
    (comp.lang.perl.misc)
  • Re: How do I add a record to an MS Access database
    ... // To build this sample from the command line, ... Console.WriteLine("tables in data set", ... foreach ... > I am using VS.NET 2003 and I have made a connection to a MS Access ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Perl Script - Not Getting Results When Using Command Line Arguments
    ... @SORTED_DIRLIST = sort @DIRLIST; ... # foreach $result ... The only section that works is the first one with no command line ... you should also move the actual work your script does into subroutines. ...
    (perl.beginners)