$filename = '/path/to/config/file'; open(CONF,"<$filename"); while(){ chomp; my ($q, $w) = split(/\t/,$_,2); $config{$q} = $w; } close(CONF); $config{'variable'} = 'new contents'; open(CONF, ">$filename"); print CONF "$_\t$config{$_}\n" for keys %config; close(CONF);