Without being able to see the code or a representative example, I am reduced to guessing. My bet is that the XML file is very large and you are running out of memory trying to store the data structure. Switch to a stream style XML parser like XML::Twig.
Usually, huge XML files will be be a set of records and you wind up just looping over the data structure you build. A better, faster way of doing this is to process the file as you go:
#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;
sub process_record {
my $rec = shift;
print "@{$rec}{qw/field1 field2 field3/}\n";
}
my $t = XML::Twig->new(
twig_handlers => {
record => sub {
my ($t, $elt) = @_;
my %record = map {
$_ => $elt->first_child($_)->text
} qw/field1 field2 field3/;
process_record(\%record);
#get rid of any memory that is being held
$t->purge;
},
}
);
$t->parse(\*DATA);
__DATA__
<root>
<record>
<field1>1</field1>
<field2>a</field2>
<field3>foo</field3>
</record>
<record>
<field1>2</field1>
<field2>b</field2>
<field3>bar</field3>
</record>
<record>
<field1>3</field1>
<field2>c</field2>
<field3>baz</field3>
</record>
</root>