#untested code! my %conf = (); foreach (`. /my/config.cfg; set`) { chomp; my ($var,$val) = /^\s*(.*?)\s*=\s*(.*)/; $conf{$var} = $val; }