my ($version,$encode);
if (m/<?xml\s+version="([^"]+)"\s+encoding="([^"]+)"/) {
($version,$encode) = ($1, $2);
print "$version\|$encode\n";
} else {
print "No match!";
}
If all your trying to get out of this is the xml version and encoding, by all means, use a regex. If you're trying to parse and entire XML document, that is a fairly non-trivial task that's better left to modules you can download from CPAN. XML::Simple may be of use, depending on how complex your XML structure is - or there are plenty of other modules for you to experiement with.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.