use XML::Simple; my $cfg = XMLin('aircracker.conf', KeepRoot => 1); sub cfghandler { my $cmd = shift; my $option = shift; my $value = shift; my $xml; if (($cmd eq 'read') && ($option) && (!$value)) { } elsif (($cmd eq 'write') && ($option) && ($value)) { if ($option eq 'daemon') { $xml = { 'system' => { 'daemon' => "$value" } }; print XMLout( { config => $xml }, AttrIndent => 1, KeepRoot => 1, NoAttr => 1, OutputFile => $cfg ); }