You can use List::MoreUtils's any
use List::MoreUtils qw(any);
if (any { $me_hash{$_} } @me_list) {
Which presumably short circuits on the first match. This function is rather simple, looking like this:
sub any (&@) {
my $f = shift;
foreach ( @_ ) {
return YES if $f->();
}
return NO;
}
Where YES and NO are defined as
use constant YES => ! 0;
use constant NO => ! 1;
Meaning you can swing your own version of this with something like
sub is_in {
my ($href, @list) = @_;
for (@list) {
return 1 if $href->{$_};
}
return 0;
}
Note that the statement you are using $me_hash{$_} can return false for values you might not consider false, such as the empty string, or zero 0.