in reply to Re^2: Return values of tags which have the same name, in an array
in thread Return values of tags which have the same name, in an array

In addition to what Eily wrote, your XML parsing code works fine for me:

use warnings; use strict; use Data::Dump; use XML::LibXML; my $xml = <<'END_XML'; <?xml version="1.0" encoding="UTF-8"?> <result> <query id="192448">Aderghal*</query> <status code="200">OK</status> <time unit="msecs">1.15</time> <completions total="1" computed="1" sent="1"> <c sc="5" dc="5" oc="5" id="19115731">aderghal</c> </completions> <hits total="5" computed="5" sent="5" first="0"> <hit score="1" id="80402"> <info><authors><author>Karim Aderghal</author><author>Alexander Khvost +ikov</author><author>Andrei Krylov</author><author>Jenny Benois-Pinea +u</author><author>Karim Afdel</author><author>Gwenaelle Catheline</au +thor></authors><title>Classification of Alzheimer Disease on Imaging +Modalities with Deep CNNs Using Cross-Modal Transfer Learning.</title +><venue>CBMS</venue><pages>345-350</pages><year>2018</year><type>Conf +erence and Workshop Papers</type><key>conf/cbms/AderghalKKBAC18</key> +<doi>10.1109/CBMS.2018.00067</doi><ee>https://doi.org/10.1109/CBMS.20 +18.00067</ee><url>https://dblp.org/rec/conf/cbms/AderghalKKBAC18</url +></info> <url>URL#80402</url> </hit> </hits> </result> END_XML my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($xml); foreach my $authors ($doc->findnodes('/result/hits/hit/info')) { print $_->textContent, "\n" for $authors->findnodes('./authors/aut +hor'); my @array = map {$_->textContent} $authors->findnodes('./authors/a +uthor'); dd @array; } __END__ Karim Aderghal Alexander Khvostikov Andrei Krylov Jenny Benois-Pineau Karim Afdel Gwenaelle Catheline ( "Karim Aderghal", "Alexander Khvostikov", "Andrei Krylov", "Jenny Benois-Pineau", "Karim Afdel", "Gwenaelle Catheline", )

As I said, perhaps you're looking for push?

my @array; foreach my $authors ($doc->findnodes('/result/hits/hit/info')) { push @array, map {$_->textContent} $authors->findnodes('./authors/author'); } # use @array here