in reply to Re^2: Extracting values from nested hashrefs
in thread Extracting values from nested hashrefs
Here is an approach that should work no matter how complicated your data structure becomes (provided the data you want remains in the form humps => d):
#! perl use strict; use warnings; use Data::Dumper; my $animals = { gnu => { humps => 0, mascot_for => 'emacs', }, dromedary => { humps => 1, mascot_for => 'perl', }, camel => { humps => 2, mascot_for => 'perl', }, }; my $flat = Dumper($animals); print "$1\n" while $flat =~ / 'humps' \s+ => \s+ (\d+) /gx;
Output:
2 0 1
TMTOWTDI.
Athanasius <°(((>< contra mundum
|
|---|