http://qs1969.pair.com?node_id=474859


in reply to How to flatten hashes?

FWIW,

use strict; use warnings; my %hash = ( accesslevels => { function => { func1 => { content => 'val1 +' }, default => { content => 'val2 +' } } } ); sub flatten { my $hash = shift; while ( my ( $k, $v ) = each %$hash ) { next unless ref $v eq 'HASH'; flatten( $v ); exists $v->{ $_ } and $hash->{ $k } = $v->{ $_ } for qw( function content ) } } use Dumpvalue; flatten( \%hash ); print Dumpvalue->new->dumpValue( \%hash ); __END__ 'accesslevels' => HASH(0x814cad4) 'default' => 'val2' 'func1' => 'val1'

the lowliest monk