Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Using an array in a hash

by Anonymous Monk
on Jan 22, 2005 at 19:47 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2025-01-14 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (42 votes). Check out past polls.