Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 scrutinizing the Monastery: (4)
As of 2014-09-19 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls