{ my @constants = qw(scroll_x scroll_y flow_x flow_y); sub which_constants { my $self = shift; return undef unless ref($self); my %hashtest; @hashtest{map { $_ - 1 } grep(/^\d+$/ && 0<=$_ && $_<@constants,@_)} = (); $self->{$constants[$_]} = exists $hashtest{$_} ? 1:0 for (0..$#constants); $self; } }