should similar scoping effects to:A for B;
when good Perl programmers discourage the former, and the principle of least surprise would lead many to expect it to behave like:map {A} B;
which is - judging from the Deparse output that danger posted - darned close to what Perl does anyways. Besides which, the things you claim are equivalent are not. Compare:for (A) {B}
The scope of $foo is different in the two cases for unsurprising reasons. (The infamous my $foo if 0; problem of persistent lexicals also shows up...)my $foo for (); map {my $foo} ();
But anyways this is a boundary case in the logic which I could see changing by accident fairly easily. It wouldn't be the first scoping rule involving a loop that was the subject of a Perl bug. Which doesn't count the fact that Perl has in the past altered in subtle ways the scoping rules around lexicals and loops. So this code is something I don't really feel comfortable with.
At this point I can see you shaking your head. But as merlyn admitted, with 6.0 all bets are off. I would have zero confidence that this scoping issue is not something that is in danger of going wrong in 6.0's automatic 5.x conversion facility. Don't believe me? Well there is one tool on a similar principle which the perl folks built already - and danger already showed that it messed up...
In reply to Re (tilly) 5: Declaring and initializing a hash with a list of keys and a list of values
by tilly
in thread Declaring and initializing a hash with a list of keys and a list of values
by merlyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |