eXile has asked for the wisdom of the Perl Monks concerning the following question:
which results in the error:my $xmldata = IO::Handle->new->fdopen(fileno(DATA),'r'); # print $xmldata->getline(); my $cr = XMLin( $xmldata );
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.my $cr = XMLin( do { local $/ ; <DATA> } );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: __DATA__ in XML::Simple and/or IO::Handle
by grantm (Parson) on Oct 03, 2006 at 20:37 UTC | |
Re: __DATA__ in XML::Simple and/or IO::Handle
by runrig (Abbot) on Oct 03, 2006 at 17:20 UTC | |
by diotalevi (Canon) on Oct 03, 2006 at 18:45 UTC |