in reply to Getting an Array Reference Into an Array

Why don't you do this:

my @myArray = qw/three-point-oh three-point-one three-point-two/; $myHash{"tres"} = \@myArray; # then do everything onto @myArray; push @myArray, "three-point-three", "three-point-four"; # And $myHash is automatically updated print join(' ', @{$myHash{"tres"}}), "\n";

Replies are listed 'Best First'.
Re^2: Getting an Array Reference Into an Array
by qazwart (Scribe) on Jun 07, 2006 at 20:34 UTC
    Why don't you do this:
    my @myArray = qw/three-point-oh three-point-one three-point-two/; $myHash{"tres"} = \@myArray; # then do everything onto @myArray;
    Because in my actual program, I'm not creating the array from scratch. The whole datastructure is given to me, and I have to manipulate it and return it back to the calling program.

    In the actual program, it is an array of a hash of a hash, and the array itself could contain thousands of members. That's why I don't want to use dereferencing and that's why I didn't want to copy it.

    I posted a simple program to demonstrate that concept.