#!/usr/bin/perl use warnings; use strict; my $hashref = { first => { foo => bar, bar => baz, flop => floodle }, second => { bar => foo, baz => bar, etc => plodle } }; foreach ( keys %{$hashref} ) { print $_ . " contains " . scalar(%{$hashref->{$_}) . " keys.\n"; }