for my $record ($root->children) { my @tmp=(); for my $col (@cols){ push @tmp,$record->first_child($col)->text; } push @data,[ @tmp ]; }