... #### ... ... #### my $conf = "/home/ember/devices/$Macaddress/$Macaddress.xml"; my $xmlfile = new XML::Simple (Outputfile => $conf, ForceArray => 1, Keyattr => 'id', RootName=>'exec'); $xml = $xmlfile->XMLin($conf); ### my $tcs=$xml->{tc}; foreach $tc (sort(keys %$tcs)){ do "TCs/$tc.tc"; $xmlfile->XMLout($xml); } ### sub Logg_TC_init { $xml->{'tc'}->{$tc}->{'id'} = $script_id; $xml->{'tc'}->{$tc}->{'version'} = $script_version; $xml->{'tc'}->{$tc}->{'objective'} = $objective; $xml->{'tc'}->{$tc}->{'time'} = time; } # End sub Logg_TC_init sub Logg_TS_add { my $id = @{ $xml->{'tc'}->{$tc}->{'ts'} } + 1; $id = sprintf '%03d', $id; push @{ $xml->{'tc'}->{$tc}->{'ts'} }, { id => "$script_id.$id", time => time, result => $result, description => $description }; } # End sub Logg_TS_add #### ...