open(CONFIG,"config_file") or die $_; while () { chomp; next if /^\s*\#/; next unless /=/; my ($key, $variable) = split(/=/,$_,2); $variable =~ s/(\$(\w+))/$config{$2}/g; $config{$key} = $variable; }