smartyollie has asked for the wisdom of the Perl Monks concerning the following question:

I am using XML::In to parse a very large XML input file, and getting out of memory error.

use XML::In;

my $var = XMLin($inputfile);

outputs:

Out of memory!

Because XML::In takes an input file as input, and creates a large structure from it, I don't think any of the standard solutions for bypassing 'out of memory' error will help me, such as processing file line by line, etc. Does anyone have any ideas for how to process a large (990 Mb) XML input file with perl?

Replies are listed 'Best First'.
Re: XML::In out of memory!
by toolic (Bishop) on May 22, 2015 at 00:30 UTC
    XML::Twig - A perl module for processing huge XML documents in tree mode

    BTW, I don't see an XML::In on CPAN. Are you really using XML::Simple (which has an XMLin function)?

Re: XML::In out of memory!
by choroba (Cardinal) on May 22, 2015 at 09:23 UTC
    Use a pull parser. XML::LibXML has one, it's called XML::LibXML::Reader, and it's accessible from XML::XSH2 via the stream command.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ