I've tried to use Lexical::Alias 0.03 because I'd like to be able to do something like:
sub foo {
alias $_[0] => my $byRef;
...
$byRef += $result;
}
but it seems Lexical::Alias doesn't work in subroutines. Is this a bug or the expected behaviour?
use strict;
use warnings;
use Lexical::Alias;
my $orig = 1;
my $alias = 99;
alias $orig => $alias;
print "$orig = $alias\n";
sub foo {
my $orig = 1;
my $alias = 99;
alias $orig => $alias;
print "foo(): $orig = $alias\n";
}
foo();
prints:
1 = 1
foo(): 1 = 99
but I believe it should print:
1 = 1
foo(): 1 = 1
My Perl is
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2002, Larry Wall
Binary build 805 provided by ActiveState Corp. http://www.ActiveState.
+com
Built 18:08:02 Feb 4 2003
running under Win2k Server.
P.S.: IMHO, it would be better if the parameters to alias() were the other way around (I assign an alias to a variable, not a variable to an alias.) and if the alias was my()d automaticaly. So that I could write:
sub foo {
alias $byRef => $_[0];
...
I think this would make more sense.
Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne