use strict; use warnings; use Data::Dumper; open my $inFH, q{<}, \ <{ type }; delete $_->{ type }; ( $key => $_ ); } map { { map { split m{=} } split } } <$inFH>; close$inFH or die $!; print Data::Dumper ->new( [ \ %hash ], [ qw{ *hash } ] ) ->Sortkeys( 1 ) ->Dumpxs(); #### %hash = ( 'first' => { 'a' => '1', 'b' => '2', 'c' => '3' }, 'second' => { 'd' => '4', 'e' => '5', 'f' => '6' }, 'third' => { 'g' => '7', 'h' => '8', 'i' => '9' } );