in reply to What data structure is this code looking for
A hash of hashes (HoH)
#! /usr/perl/bin use warnings; use strict; use Data::Dumper; my $abc = { one => { oneone => 11, onetwo => 12, }, two => { twoone => 21, twotwo => 22, } }; foreach my $key (keys %{$abc}) { if ( ref $abc->{$key} eq 'HASH' ) { for my $subkey (keys %{$abc->{$key}}){ printf qq{%s -> %s\n}, $subkey, $abc->{$key}{$subkey}; } } }
onetwo -> 12 oneone -> 11 twotwo -> 22 twoone -> 21
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: What data structure is this code looking for
by mhearse (Chaplain) on Nov 15, 2011 at 15:52 UTC | |
by wfsp (Abbot) on Nov 15, 2011 at 15:57 UTC | |
by jethro (Monsignor) on Nov 15, 2011 at 15:59 UTC | |
by MidLifeXis (Monsignor) on Nov 15, 2011 at 17:00 UTC |
In Section
Seekers of Perl Wisdom