use Object::Enum qw(Enum); my $color = Enum([ qw(red yellow green) ]); # ... later if ($color->is_red) { # it can't be yellow or green WWW: https://metacpan.org/release/Object-Enum