# assuming that DATA contains the config my @hosts; do{ &new_host() if /{/ } while ; sub new_host { my $data = {}; until (defined ($_=) && $_=~/}/) { chomp; my (undef,$field,$value)=split /^[\t ]*([^=]*)=/,$_; $data->{$field}=$value; } push @hosts,$data; }