Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Direct reference to any element in a hash-of-hash

by neniro (Priest)
on Jun 15, 2006 at 12:45 UTC ( #555485=note: print w/ replies, xml ) Need Help??


in reply to Direct reference to any element in a hash-of-hash

If you don't want to get all those values or keys, you could use each to get just the first pair:

#!/usr/bin/perl use strict; use warnings; my $hoh = { apples => { source => 'uk', colour => 'red', }, pears => { source => 'uk', colour => 'green', }, bananas => { source => 'uk', colour => 'yellow', }, }; my (undef, $v) = each %$hoh; print $v->{'source'}, "\n";
If you want to use each later in your script, remember to reset the iterator.


Comment on Re: Direct reference to any element in a hash-of-hash
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2015-07-06 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (72 votes), past polls