Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: How do I refer to an element of a hash of arrays as an array

by arturo (Vicar)
on Mar 08, 2001 at 19:17 UTC ( #62966=note: print w/replies, xml ) Need Help??

in reply to How do I refer to an element of a hash of arrays as an array

Since hash values can only be scalars, the value is a reference to an array. That is, it's like a pointer. (Try print "$h{'one'}\n" and see what you get.)

To get at the thing the reference points to, you need to explicitly dereference it. To get at the array, do

my @a = @{ $h{one} };
By enclosing something in the @{ } construction, you're saying that you want the array to which that reference points.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://62966]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2023-03-25 05:20 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (62 votes). Check out past polls.