Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: Extracting values from nested hashrefs

by Marshall (Abbot)
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";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993214]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2017-06-25 00:43 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (563 votes). Check out past polls.