my @AoH_attribs; open( FILE, "<$file" ); { local $/ = ''; # empty string is "magic" for "paragraph-mode" while () # read a group of lines into $_ { my %hash = (); my $itemname = ( /^\[(.*?)\]/ ) ? $1 : 'NO_KEY'; next if ( !/=/ or $hashkey eq 'NO_KEY' ); $hash{item} = $itemname; for my $line ( split /\n/ ) { next unless ( $line =~ /=/ ); my ( $attrib, $value ) = split /=/, $line; $hash{$attrib} = $value; } push @AoH_attribs, { %hash }; # note use of curly braces } } close FILE; # now, @AoH_attribs contains a list of hash refs, one for each input block; # you can access each hash like this: for my $itemref ( @AoH_attribs ) { my %itemhash = %$itemref; print "$_ = $itemhash{$_}\n" for ( sort keys %itemhash ); print "\n"; }