Fideist11 has asked for the wisdom of the Perl Monks concerning the following question:
#This bool function returns whether the second argument #string can be built with the first arguments letters sub match($$$) { my ($self,$letters,$word) = @_; $letters = lc($letters); $word = lc($word); #Now we build our hashes my (%letter_hash, %word_hash); while($letters) { $letter_hash{chop($letters)}++; } while($word) { $word_hash{chop($word)}++; } #Now to analyze my ($key, $value); while(($key,$value) = each(%word_hash)) { $letter_hash{$key} = $letter_hash{$key} - $value; return 0 if ($letter_hash{$key} < 0); } #Must be good return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding One String in Another
by Abigail-II (Bishop) on Jul 31, 2002 at 16:51 UTC | |
|
Re: Finding One String in Another
by particle (Vicar) on Jul 31, 2002 at 16:38 UTC | |
|
Re: Finding One String in Another
by marvell (Pilgrim) on Jul 31, 2002 at 16:42 UTC | |
|
Re: Finding One String in Another
by RMGir (Prior) on Jul 31, 2002 at 16:45 UTC | |
|
Re: Finding One String in Another
by fglock (Vicar) on Jul 31, 2002 at 16:46 UTC | |
by Abigail-II (Bishop) on Jul 31, 2002 at 16:59 UTC | |
|
Re: Finding One String in Another
by Fideist11 (Sexton) on Jul 31, 2002 at 16:30 UTC | |
|
Re: Finding One String in Another
by marvell (Pilgrim) on Jul 31, 2002 at 16:52 UTC |