use strict; use warnings; my ($sec, %config); while () { $sec = $1 and next if /^\[([^\]]+)\]/; $config{$sec}{$1} = $2 if /^\s*([^=]+)\s*=\s*"([^"]+)"/; } =cut we now have ths following structure: %config = ( client => { host = 'localhost', port = '8080' }, server => { host => 'localhost', port => '8900', timeout => '60' } ); =cut __DATA__ [client] host="localhost" port="8080" [server] host="localhost" port="8900" timeout="60"