in reply to Unblessed Reference Error, XMLin
$xml = $xml->XMLin($xmlData);In each loop, you're replacing the previous value in $xml with new data. That is bound to go wrong the second time you go through the loop body.
Most likely you need to use a different variable.
In Section
Seekers of Perl Wisdom