use CGI; my $query=CGI::new(); my %config; my @params; if($query->param('submit') eq "save"){ #if we want to save new parameters open log file #and read old settings into config hash if("test.cfg" -e){ open FILE, "){ if(/(.*)=(.*)/){ $config{$1}=$2; } } close FILE; } @params=$query->param(); #add/overwrite params just submitted in config hash foreach(@params){ $config{$_}=$query->param($_) unless $_ eq "submit"; } #write all the config key/value pairs out to the file open FILE, ">test.cfg" || die "Can't open! $!"; foreach(keys %config){ print FILE "$_=$config{$_}\n"; } close FILE; }