# $hash{$key} = { field1 => 'value', ... }; my @keys = keys %{$hash{(keys %hash)[0]}}; my $format = "%10s " . ("%10s " x @keys) . "\n"; printf $format, "Key", @keys; foreach my $key (keys %hash) { printf $format, $key, @{$hash{$key}}{@keys}; }