Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Extracting values from nested hashrefs

by Marshall (Prior)
on Sep 12, 2012 at 11:51 UTC ( #993214=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Extracting values from nested hashrefs
in thread Extracting values from nested hashrefs

Why be more cryptic that you need to be?
Doing so will not be more efficient.

#!/usr/bin/perl -w use strict; my $animals = { gnu => { humps => 0, mascot_for => 'emacs', }, dromedary => { humps => 1, mascot_for => 'perl', }, camel => { humps => 2, mascot_for => 'perl', }, }; foreach my $critter (keys %$animals) { print "$critter "; #camel gnu dromedary } print "\n"; foreach my $critter (keys %$animals) #sort if you want to { print "$animals->{$critter}{humps} "; #2 0 1 } print "\n";


Comment on Re^3: Extracting values from nested hashrefs
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2015-07-31 02:36 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 (274 votes), past polls