use v5.20; use List::Util qw(any none); # Allows the first arg to be an array or a ref # If the second arg is absent, $_ is used instead sub in:prototype(+_) { any { $_[1] eq $_ } @{ $_[0] } } sub notin:prototype(+_) { none { $_[1] eq $_ } @{ $_[0] } } my @list = 'A'..'Z'; my $in = 'C'; say 'IN' if in @list, $in; $_ = '1'; say 'OUT' if notin \@list; say 'NOPE' if in @list, '2'; say 'NOPE' if notin @list, 'D';