in reply to accessing XML-declarations
Access it through the actualEncoding method() of the document object:
my $doc = $parser->parse_file("test.xml"); print $doc->actualEncoding(); [download]