in reply to copying array from a hash reference
The problem is that @AniAry = $AniType{cats} does not result in a copy of the array. I've tried the following as well:
@AniAry = @{ $AniType{cats} };
...
I don't understand what you mean in the second code example above. This works (i.e., copies the referenced array) for me:
>perl -wMstrict -le "my %AniType = ( cats => ['I', 'like', 'cats'], dogs => ['I', 'like', 'dogs'], none => ['I', 'like', 'neither'], both => ['I', 'like', 'both'], ); ;; my @AniAry = @{ $AniType{cats} }; printf qq{'$_' } for @AniAry; " 'I' 'like' 'cats'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: copying array from a hash reference
by Greg_R (Novice) on Sep 28, 2011 at 22:28 UTC |