%valid); my($name, %valid); if(!(@_ == 1 && ref($_[0]) eq 'ARRAY')){ if(!(@_ == 1 && ref($_[0]) eq 'ARRAY')){ $name = shift; $name = shift; } } %valid = map{ $_ => undef } %valid = map{ $_ => undef } (@_ == 1 && ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_); (@_ == 1 && ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_); # EnumType # EnumType return _define_type 1, $name => ( return _define_type 1, $name => ( as => 'Str', as => 'Str', optimized_as => sub{ optimized_as => sub{ return defined($_[0]) && !ref($_[0]) && exists $valid{$_[0]}; return defined($_[0]) && !ref($_[0]) && exists $valid{$_[0]}; }, }, ); ); } }