Okay, so it's easy to create a reference to an array...
my @a;
my $b=\@a;
#can now reference the same list of scalars from either @$b or @a
But how can I do this in reverse? For instance:
my $a=[1..4];
my @b;
#some magic happens here and now @b is an alias for @$a
@b=(6..10);
print "@$a\n"; #should print "6 7 8 9 10"
I assume this would happen through typeglobs, but those just elude me. Ideas?
Also it would be nice to do the same for hashes as well as arrays.
EDIT: This seems to work, but it's a tad kludgy as it just copies the anon array elements to the "alias" and then re-points itself to the array:
my @b=@$a;
$a=\@b;
Any better ideas?