my %CFG; ... while() { next if (/^\s*(#.*)?$/); my ($key, $value) = split(/[\s\t]*=[\s\t]*/); $CFG{$key} = $value; }