my $t = XML::Twig->new(); $t->parsefile( $Globals::input_xml_dir."TimesheetLoad_1.xml" ); my $rt = $t->root; # NikuDataBus my $hd = $rt->first_child( 'Header' ); my $tp = $rt->first_child( 'Customers' ); $tp->cut; my @tp1 = $tp->children( 'Customer' ); my $count = 0; foreach my $tp1 (@tp1) { $tp1->cut; $tp1->paste( after => $hd, $rt ); my $out; open ($out, ">$Globals::input_xml_dir\\twigs\\CustomerLoad_$count.xml"); $rt->print( $out ); close $out; $tp1->cut; $count++; }