It could be even simpler than that. Assuming operations on an array, if one can get the array into a function and decide on a regex to match the desired language:
sub func {
...
return unless my @wanted = grep m{ $rx_wanted }xms, @voices;
return $wanted[ -1 ];
}
func returns
undef if no desired language is found, the
last language if more than one is found, and the
first if there is only one. If one didn't want the last language in the case of more than one, maybe something like
return $wanted[ @wamted > 1 ? 1 : 0 ];
Give a man a fish: <%-{-{-{-<