in reply to Identifying bigrams and making a note of which ones exist
If you really need an array, then change the foreach into a for@bigram = ( 'aa' .. 'zz' ); @bigram_list = ("ac" , "ab" , "wd" , "xs" ); $bigram_str = join " " @bigram; my %bigram_exist; foreach $bigram_test (@bigram_list) { if ( $bigram_str =~ m/$bigram_test/ { $bigram_exist{$bigram_test}=1; } else { $bigram_exist{$bigram_test} = 0; { }
either way you'll obtain a hash or an array with as many keys/items as your list.(...) my @bigram_exist; for (i=0 ; i<=@bigram_list ; i++) { if ( $bigram_str =~ m/$bigram_list[i]/ { $bigram_exist[i]= 1 ; } else { $bigram_exist[i] = 0; { }
|
|---|