The most general ...
That method of aliasing is interesting and occasionally useful, but it is hardly "The most general".
Besides that a reference to an array of aliases is hardly as convenient as a typeglob aliased array, it is also a very fragile structure. As soon you do anything that modifies the referenced array -- rather than the things aliased by its contents -- the aliases cease to be aliases.
Eg. Here I've used splice to modify the array, but push, pop, shift, unshift, assignments to $#$silly and anything else will silently break the aliasing affect resulting in two entirely separate, unconnected arrays:
#! perl -slw
use strict;
my @a2 = 'a'..'z';
my $silly = sub{ \@_ }->( @a2 );
splice @{ $silly }, 12, 1, 'the middle';
print "@{ $silly }";
print "@a2";
__END__
C:\test>junk
a b c d e f g h i j k l the middle n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
|