On a related note, I cannot believe that you really want to create temporary files every time this is called. BTW, TMTOWTDI:
local $/;
open(IN,qq|adatafile.txt|) or die $!;
my $infile = <IN>;
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;
Celebrate Intellectual Diversity