http://www.perlmonks.org?node_id=375374


in reply to Aliasing values, not variables

Sorry for not coming up with this ugly solution while you were asking about it in the CB:

#!/usr/bin/perl -w use strict; sub alias{ \@_ }; my @a = (1,"world"); my $arr = alias( $a[0], $a[0], $a[1] ); $arr->[0] = "hello"; print "@$arr\n";

I learned this ugly trick from demerphq while he was testing the aliasing features of his DDS module, so maybe looking at what the dumpers and their tests do might give you some more inspiration.

Updated: Fixed typo in sub alias, spotted by nothingmuch

Updated: I use strict; but the code won't run like that. That should teach me about posting when I don't cut'n'paste my code ... Spotted by The Mad Hatter