while (defined(my $line = $fh->getline())) {
while ( $line =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})<\/ip>/g) {
print "$1\n";
}
}
use XML::LibXML;
use feature qw(say);
my $filename = "Sample.xml";
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($filename);
my $root = $doc->getDocumentElement;
foreach my $node ( $doc->findnodes('//ip') ) {
my $value = $node->textContent();
say $value;
}
STATUS OF THIS MODULE
The use of this module in new code is discouraged. Other modules are available which provide more straightforward and consistent interfaces. In particular, XML::LibXML is highly recommended.
The major problems with this module are the large number of options and the arbitrary ways in which these options interact - often with unexpected results.
Patches with bug fixes and documentation fixes are welcome, but new features are unlikely to be added.