Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Hash of arrays

by FamousLongAgo (Friar)
on Oct 27, 2002 at 18:30 UTC ( #208361=note: print w/replies, xml ) Need Help??

in reply to Hash of arrays

You're almost there - you are correctly storing the array reference in the hash. Remember, however, that a reference in perl is just a scalar -- if you want to get at the thing it's a reference to, you'll need to dereference it first:
while ( my ($key, $reference) = each %id_veritasHash){ foreach my $temp (@{$reference}){ print "$key, $temp\n"; } }
I've put in some my declarations just for good coding style. The key bit is @{$reference}, which could also be written @$reference. This is where you dereference the scalar to get at its referent, the stored array.

Reference syntax is tricky, and so it the concept, if you are just getting started. I suggest reading through perlreftut and going on from there. See if you can figure out the concept to your satisfaction, and then tackle the syntax.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2023-02-06 22:32 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (37 votes). Check out past polls.