Because you copied the referenced array's contents to a local copy and then modfied the local copy. You never copied it back. Try
use warnings; use strict; my @a = ("a", "b", "c"); Foo(\@a); print "$_ " foreach(@a); sub Foo { my $refA = shift; # my @b = @$refA; $refA->[0] = "hello"; $refA->[1] = "world"; $refA->[2] = "Perl"; }
In reply to Re: Changing items of an array in a function
by Anonymous Monk
in thread Changing items of an array in a function
by abhishes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |