in reply to Create an XML file from input text file

I usually use XML::LibXML to handle XML.
#!/usr/bin/perl use strict; use warnings; use XML::LibXML; my $item_list = shift; my $xml = << '__XML__'; <BulkUpdate> <UpdateSets> <UpdateSet> <type name="MyType" /> <where> <cond_prop attrName="ID" cond_operator="="/> </where> <update> <update_prop attrName="sh4_SAP_ID" attrValue="" /> </update> </UpdateSet> </UpdateSets> </BulkUpdate> __XML__ my $dom = 'XML::LibXML'->load_xml(string => $xml); my ($sets) = $dom->findnodes('/BulkUpdate/UpdateSets'); my ($update) = $sets->findnodes('UpdateSet'); open my $in, '<', $item_list or die $!; while (<$in>) { chomp; my $set; if ($. > 1) { $set = $update->cloneNode(1); $sets->appendChild($set); } else { ($set) = $dom->findnodes('/BulkUpdate/UpdateSets/UpdateSet[las +t()]'); } my ($cond_prop) = $set->findnodes('where/cond_prop'); $cond_prop->{attrValue} = $_; } print $dom;

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]