sub slex { my $h = shift; return map { exists $h->{$_} || 0 } @_ } my %h = map { $_ => 1 } 'a'..'t'; my @bool = slex \%h, 'a'..'z'; print "@bool\n";