in reply to Copying an array or hash
If you pass an array or a hash, then modifying it should not modify the original.
my @foo = qw(x y z); bar(@foo)
Update: Boy, do I feel like a fool.
Of course, if you pass as a reference...
my @foo = qw(x y z); bar(\@foo)
...or if you are dealing with a reference in the first place, then the original will be modified. To avoid this, you can dereference the array (or hash) within the subroutine. How you do that is described in perldoc perlref
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Copying an array or hash
by Fletch (Bishop) on Dec 05, 2005 at 14:11 UTC |