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


in reply to How to flatten hashes?

Not sure this qualifies as more elegant, or just more obfuscated than rev_1318's solution.

use YAML; my %h = ( 'accesslevels' => { 'function' => { 'func1' => { 'content' => 'val1' }, 'default' => { 'content' => 'val2' } } }, 'accesslevels2' => { 'function' => { 'func1' => { 'content' => 'val1' }, 'default' => { 'content' => 'val2' } } }); for my $L (values %h) { my (%tmp, $k, $v); for (values %$L) { $tmp{$k} = $$v{content} while ($k,$v) = each %$_; } $L = \%tmp; } print Dump \%h;

Good Day,
    Dean