in reply to Copying a hash element into an array as a list

The monks have provided a suitable solution to your problem. However, if you could just change the base of the problem a bit, then make it

$hash{'element'} = [ "A".."E" ]; # reference to anonymous array contai +ning A-E. my @array = @{ $hash{'element'} }; # dereference and copy the array in +to @array. print "$array[0]\n", $hash{'element'}->[0], "\n";

Replies are listed 'Best First'.
Re: Re: Copying a hash element into an array as a list
by SkipHuffman (Monk) on Mar 24, 2004 at 17:58 UTC

    Yes, the monks did provide what I need. I considered using a hash reference, but I use that same hash natively several other places, just here I need to treat its contents as an array.

    Thank you and the other monks!

      I considered using a hash reference ...

      You mean array reference, right? The reference isn't to what's holding it, it's to what's being held.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

        Yeah. Actually I considered ordering the data in a variety of ways. The Hash of Strings containing Lists makes the most sense to me for my data processing. At some point a light may dawn and I redesign the entire application with a new structure, but not at this point.

        thanks