'Waypoint' => [ "@waypoints"], #### push(@waypoints, "{'Longitude' => '$point[0]', 'Latitu +de' => '$point[1]', 'SequenceNumber' => '$count'}"); #### push(@waypoints, { Longitude => $point[0], Latitude => $point[1], SequenceNumber => $count } ); #### use strict; use warnings; use XML::Simple; my $xml = new XML::Simple ( RootName => 'Task', XMLDecl => '', ); my @waypoints = ( { Long => 1, Lat => 2, SeqNo => 1 }, { Long => 3, Lat => 4, SeqNo => 2 }, ); my $waydata = { 'xmlns' => "http://Task.CUIntegration.com", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xsi:schemaLocation' => "http://Task.CUIntegration.com Task.xsd", 'ID' => ['ID'], 'Type' => ['Loop'], 'Destination' => ['Velocity'], 'Waypoint' => [ @waypoints ], }; print $xml->XMLout($waydata);