|laziness, impatience, and hubris|
__DATA__ in XML::Simple and/or IO::Handleby eXile (Priest)
|on Oct 03, 2006 at 17:07 UTC||Need Help??|
eXile has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a problem in reading an XML file that I want to include in a __DATA__ section. My first try was using the XML in the __DATA__ section as follows: my $cr = XMLin( *DATA ); After reading the XML::Simple docs, I saw it required an IO::Handle object, so I tried this:
which results in the error:
Unable to recognise encoding of this document at /usr/local/lib/perl5/site_perl/5.8.7/XML/SAX/PurePerl/EncodingDetect.pm line 96. Document requires an element Ln: 1, Col: 0
Which leads me to believe the $xmldata IO::Handle doesn't return any lines, however, If I uncomment the getline() line from the code above it prints a line, starting at character 12199 of my XML file.
I got 2 questions about this:
How can I read an XML file from a __DATA__ section (preferably with XML::Simple) ?
What magic happens with the DATA filehandle? Is some predefined number of characters read in from it at compilation time?
UPDATE: never mind question number 1, this solves my problem:
I'm still interested in what happend though.