@bigram = ( 'aa' .. 'zz' ); # magic! #### # make a "set" of the ones in the list: my %bigram_list; @bigram_list{@bigram_list} = (); # corresponds to (and same size as) @bigram. my @bigrams_existing = map { exists $bigram_list{$_} ? 1 : 0 } @bigram;