in an expression such as
The first $item on the line is the one you're declaring lexical while the second $item is whatever $item is available in the enclosing scope. Your lexical $item isn't available until after that statement has completely executed.my $item = $item;
Perl 6 will change this behavior and make variables available as soon as possible. In order to get the old behavior you'll need to do something like:
my $item = $OUTER::item;
In reply to Re: Scoping question
by duff
in thread Scoping question
by Dr. Mu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |