foreach my $i ($list->tagNames()) { if ($i eq $j) { print "$tag found\n"; last; } }