Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Extracting values from nested hashrefs

by loris (Hermit)
on Sep 12, 2012 at 09:51 UTC ( #993201=note: print w/ replies, xml ) Need Help??


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

The ordering happens to be irrelevant, so the unsorted version is fine. I see from your solution that the distinction I was trying to make between explicit and implicit was a bit foolish. What I meant was that I wanted to do things in a nifty perl-like way, as you have done, rather than in a dull, C-like way.

Thanks,

loris


Comment on Re^2: Extracting values from nested hashrefs
Re^3: Extracting values from nested hashrefs
by Marshall (Prior) on Sep 12, 2012 at 11:51 UTC
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2014-08-29 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls