http://qs321.pair.com?node_id=1194918

jfrm has asked for the wisdom of the Perl Monks concerning the following question:

I have been uploading an XML file to a service provider for a long time with the first line output as:
$cureq .= '<?xml version="1.0" encoding="latin1"?>'."\n"; $cureq .= # lots of other xml stuff open (XML, ">$xmlfile") or return("Could not open $xmlfile"); print $cureq; close XML or return("Could not close $xmlfile");
Now I have to change the encoding from latin1 to UTF-8 and having read around quite a lot now, I realise that I just don't get it. I have tried changing what I thought were the critical 2 lines viz:
$cureq .= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; open (XML, '>:encoding(UTF-8)', $xmlfile) or return("Could not open $x +mlfile");
This creates the file but my service provider now returns 'Invalid XML'. I just don't get it and what's more I cannot think of a way to debug it or investigate more deeply. Any clues for this poor padawan would be appreciated.