in reply to a natural way of expressing things

Knowing the bigger picture would help here because the "best" answer depends a lot on context. The general answer to "is this thing an element of that set" is to use a hash:

my %hash; @hash{val1, val2, val3} = undef; if (exists $hash{$test}) { }

But if you want "do something if this thing is an element of that set" then you can use a hash to dispatch:

my %hash = (val1 => \&task1, val2 => \&task2, val3 => \&task3); if (exists $hash{$test}) { $hash{$test}->(); }

DWIM is Perl's answer to Gödel