use warnings; use strict; use Data::Dump; use XML::LibXML; my $xml = <<'END_XML'; Aderghal* OK aderghal Karim AderghalAlexander KhvostikovAndrei KrylovJenny Benois-PineauKarim AfdelGwenaelle CathelineClassification of Alzheimer Disease on Imaging Modalities with Deep CNNs Using Cross-Modal Transfer Learning.CBMS345-3502018Conference and Workshop Papersconf/cbms/AderghalKKBAC1810.1109/CBMS.2018.00067https://doi.org/10.1109/CBMS.2018.00067https://dblp.org/rec/conf/cbms/AderghalKKBAC18 URL#80402 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/author'); my @array = map {$_->textContent} $authors->findnodes('./authors/author'); 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", ) #### my @array; foreach my $authors ($doc->findnodes('/result/hits/hit/info')) { push @array, map {$_->textContent} $authors->findnodes('./authors/author'); } # use @array here