On Tue, Jul 21, 2009 at 12:45:04PM +0200, Rafael Garcia-Suarez wrote:
> Ah, you're right. The parser has this line :
> switch : label GIVEN '(' remember mydefsv mexpr ')' mblock
> where mydefsv is an empty rule that lexicalizes $_.
> But then the code I pasted above could probably be simplified.
So if I've understood this correctly, given() adds a lexical $_ to the
scope, and there's a bug in List::Util::first in that it doesn't work with
a lexical $_? So not a bug in given/smartmatch?
use List::Util qw/first/;
print "ok outside\n" if first { $_ } 1;
{
my $_ = 0;
print "ok inside\n" if first { $_ } 1;
}
outputs:
ok outside
--
Technology is dominated by two types of people: those who understand what
they do not manage, and those who manage what they do not understand.
Thread Previous
|
Thread Next