# place to put everything my @queue_managers; # a hash to store the key/value pairs for each queue manager my %conf = (); while () { # see if we have a new "queuemanager" line and if there's any data to save if ( /^QueueManager/ && %conf ) { # save what we have already stored push @queue_managers, { %conf }; # clear the hash for the next one %conf=(); next; } # now check key/value pair lines and if we've got one, put its # data into the hash. I'm assuming that values are bracketed by # spaces, so I just grab the longest set of non-spaces if ( my ($key, $value ) = /^\s*(\w+)\s*=\s*(\S+)/ ) { $conf{$key} = $value; } } # ahh, the last entry probably hasn't been saved push @queue_managers, {%conf} if %conf;