http://www.perlmonks.org?node_id=993201


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

Replies are listed 'Best First'.
Re^3: Extracting values from nested hashrefs
by Marshall (Canon) 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";