in reply to Finding One String in Another
This will work even if letters or words ends in a zero character, which would end your loop.#Now we build our hashes foreach(split "",$letters) { $letter_hash{$_}++; } foreach(split "",$word) { $word_hash{$_}++; } while(my($key, $value)=each(%word_hash)) { # no need to update $letter_hash{$key} return 0 if $letter_hash{$key}<$value; } return 1;
|
|---|