Good day bros. I am trying to implement some
sample code in mod MCE for implementing Strassen's algorithm for matrix multiplication. At the beginning of the subroutines is the following:
######################################################################
+#########
# * # * # * # * # * # * # * # * # * # * # * # * # * # * # * # * # * #
+ * # * #
######################################################################
+#########
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;
}
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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.