cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
My question is about the my @p. This occurs after the completion of the main script, yet it is declared as a local variable so it is within the scope of the main script. It is referenced in sub store_result but is outside its scope. My debugger (Komodo) doesn't flag this as a problem, which it seems like it should. Does anyone know what's going on here? I have not used MCE so maybe it's something peculiar about it?###################################################################### +######### # * # * # * # * # * # * # * # * # * # * # * # * # * # * # * # * # * # + * # * # ###################################################################### +######### my @p; sub store_result { my ($n, $result) = @_; $p[$n] = $result; return; } sub configure_and_spawn_mce { return MCE->new( max_workers => 7, user_func => sub { my $self = $_[0]; my $data = $self->{user_data}; my $tam = $data->[3]; my $result = [ ]; strassen_r($data->[0], $data->[1], $result, $tam); $self->do('store_result', $data->[2], $result); } )->spawn; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MCE seemingly stray array in sample code for Strassen's algorithm
by kcott (Archbishop) on Apr 14, 2013 at 01:38 UTC | |
by BillKSmith (Monsignor) on Apr 14, 2013 at 02:33 UTC | |
by NetWallah (Canon) on Apr 14, 2013 at 05:32 UTC | |
by cormanaz (Deacon) on Apr 14, 2013 at 12:09 UTC | |
by marioroy (Prior) on Dec 13, 2014 at 02:51 UTC |