In Perl 5.10.1:
#!/usr/bin/perl
my @a = (1, 2, 3);
my $b = \@a;
print join('', @{$b}) . "\n";
@a = (6, 7, 8);
print join('', @{$b}) . "\n";
This prints 123 then 678. However, I'd like to get 123 both times (i.e. reassigning the value of @a
will not change the array that $b
references). How can I do this?