local $/; open(IN,qq|adatafile.txt|) or die $!; my $infile = ; my $begin_stuff; my $end_stuff; my %mid_stuff; close(IN); if($infile=~m/(.*)\#\s+__START_CONFIG__/s){ $begin_stuff = $1; } if($infile=~m/__START_CONFIG__(.*)\# __END_CONFIG__/s){ my $tmp = $1; while($tmp=~m/([^=\s]+)=([^=]+)\n/g){ $mid_stuff{$1} = $2; } } #if ..oh hell, you get the bloody idea... print Dumper \%mid_stuff;