in reply to Re: Lexical::Alias & subroutines
in thread Lexical::Alias & subroutines

This is just a scoping issue. If you have a lexical at the outer scope and you declare a lexical at the inner scope (as in your example) the inner scope only sees the new version not the old. As you did the aliasing at the outer level and not the inner, the inner lexical isn't aliased. The outer will still be so once you return.
Nope, you're missing the point. He did exactly the same thing inside the sub as outside, independently... Yet it works outside the sub, but not inside. I agree that that is very unexpected behavior. I'd call it a bug.
use Lexical::Alias; @a = (5); my $x = 1; alias($a[0],$x); print "$x\n"; # prints 5 sub foo { my $y = 2; alias($a[0],$y); print "$y\n"; # prints 2 } foo();

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.