Regarding your point #3, I believe that, exactly because $a and $b are globals, closing over them doesn't make much sense. You'll have to copy the values out of the global variables (well, package lexicals), if you need to retain the values as found during the reduce call. As an aside, I've never used assignment to $a in reduce - I thought the assignment was implicit from the code return, as in:
my $sum = reduce { $a + $b } 0,1,2; # instead of my $sum = reduce { $a = $a + $b } 0,1,2;
As for you needing that second inner block, I don't know what happens there. On 5.8.5, I get a "deep recursion" in the call to $combo if I remove that second block. I guess it has something to do with pad allocation and maybe the known closure bug where you need to mention the variables to be closed over in the inner block in the intermediate block - we have a double-nesting of anonymous subs here too, the code block passed to reduce and the anonymous sub in there.
In reply to Re: Bugs? Or only in my expectations?
by Corion
in thread Bugs? Or only in my expectations?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |