# this routine takes a search text and a list of XML elements and # searches them for the text sub candidate_generator { my ($search_text, @data) = @_; grep { grep { $_->text eq $search_text } $_->children } @data; }