Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: Using an array in a hash

by Anonymous Monk
on Jan 22, 2005 at 19:47 UTC ( #424265=note: print w/replies, xml ) Need Help??

in reply to Re: Using an array in a hash
in thread Using an array in a hash

The person asked for how to get a array back OUT OF A HASH. None of you have answered the question. I would like to know how to do this as well. Here what I tried and it failed. my @host_type= qw { a b c d e} ; my $j = "small" ; my %vendor_size_hash = ($j => \@host_type ) ; print "\@vendor_size_hash{$j} \n " ;

Replies are listed 'Best First'.
Re^3: Using an array in a hash
by friedo (Prior) on Jan 22, 2005 at 20:11 UTC
    There are two ways to dereference an array, depending on what you need to do. See perlref and perlreftut for the details.

    In short, to dereference an entire array, use:

    my @array = @{ $vendor_size_hash{$j} };
    To dereference a single element in the array, use:
    my $el = $vendor_size_hash{$j}[$number];

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2023-11-28 17:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found