Indeed in the first case you create a closure around a lexical variable. But $_ is not lexically scoped. So the anonymous sub you're putting on the right side of => prints $_ as it founds it when it is run. That is undef, hence the warning.
It's just the same with:
In this sense it seems that starting with bleædperl 5.9.1 things will be different.my @closures = map sub { $_ }, 1..5; # won't "work" my @closures = map { my $v=$_; sub { $v } } 1..5; # "works"
In reply to Re: Are we seeing syntax inconsistency?
by blazar
in thread Are we seeing syntax inconsistency?
by TibetPerlMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |