Вопрос

I need to process hundreds of xml files. I'm using XML::LibXML. I'm quite new to perl and I don't understand how to close the fist XML parsed file, before opening the new one

Example

use XML::LibXML;
my ($parser, $doc, $node);
foreach my $xmlfullname (@xmlfullnamearray) {
    $parser = XML::LibXML->new();
    $doc    = $parser->parse_file($xmlfullname);
    $node   = $doc->findnodes("/root/node");
    ...
}

Thanks to all, Riccardo

Это было полезно?

Решение

By losing all references to it, which you already do by overwriting all the variables.

A little cleaner and clearer:

use XML::LibXML;

my $parser = XML::LibXML->new();

foreach my $xmlfullname (@xmlfullnamearray) {
    my $doc  = $parser->parse_file($xmlfullname);
    my $node = $doc->findnodes("/root/node");
    ...
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top