I've tried to use Lexical::Alias 0.03 because I'd like to be able to do something like:
but it seems Lexical::Alias doesn't work in subroutines. Is this a bug or the expected behaviour?sub foo { alias $_[0] => my $byRef; ... $byRef += $result; }
prints: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();
but I believe it should print:1 = 1 foo(): 1 = 99
1 = 1 foo(): 1 = 1
My Perl is
running under Win2k Server.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
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:
I think this would make more sense.sub foo { alias $byRef => $_[0]; ...
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
In reply to Lexical::Alias & subroutines by Jenda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |