Pure Perl has neither an explicit alias operator
You can (ab)use typeglobs for this, at least for package variables. For instance:
#!/usr/bin/perl no strict; use warnings; use feature qw/say/; $a = 42; *b = *a; say $b; # 42 $b = 69; say $a; # 69
I can't think of a way of doing this with lexicals off the top of my head, though.
nor an explicit unalias operator.²
So if a scalar variable $a is an alias to $b you can't easily say $a=42 without changing $b , i.e. replacing the alias in the $a -"slot" with a literal 42.¹
I don't think this is needed. Suppose that you have variables - let's say lexicals - $a and $b, with the latter being aliased to the former. Unalias $a would mean creating a new lexical that's not related to $b anymore, so why not just declare a new lexical with the same value (my $c = $b) and use that instead? The result's the same, and it's arguably clearer, since if you look at any line in isolation there's no confusion over whether $a is (still) aliased to $b anymore.
OTOH there's something to be said in favor of explicit alias and unalias operators as well. I'd not be surprised at all if there were CPAN modules that implemented this.
In reply to Re^3: Accessing Arguments inside Subroutines via @_
by AppleFritter
in thread Accessing Arguments inside Subroutines via @_
by citi2015
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |