#!/usr/bin/perl -w use strict; my $aref = [1, 2, 3]; my @a = @$aref; # this line $a[1] = 99; print \"aref = @$aref\\n\"; print \"a = @a\\n\"; <
#!/usr/bin/perl -w use strict; my $aref = [1, 2, 3]; my @a = @$aref; # this line $a[1] = 99; print \"aref = @$aref\\n\"; print \"a = @a\\n\";
To expand on Borodin's answer, I've tested this with the Lexical::Alias module:
#!/usr/bin/perl -w use strict; use Lexical::Alias 'alias_a'; my $aref = [1, 2, 3]; my @a; alias_a(@$aref, @a); $a[1] = 99; print "aref = @$aref\n"; print "a = @a\n";