in reply to Re: how to find hash keys in a string ?
in thread how to find hash keys in a string ?
You have chosen to work of words in the string rather than the keys of the hash. If someone were really doing this type of analysis on a large data set, it might be worthwhile to have multiple methods and choose the best one based on the data set. For instance - imagine that there are only 3 hash keys, but the string is 1,500 words long. It certainly doesn't make sense to use this method.
You have also assumed that the hash keys will not contain any spaces. My solution allows for this, but still has the requirement of having a word border on both ends. For insance:
Your method will not work in either case. My method will correctly match in $string but will correctly fail in $otherstring.my $temphash{'good boy'} = "blah"; my $string = "He was a good boy when we went to the store"; my $otherstring = "He is worthless, not a good boyfriend at all";
My hat is off to you for such an innovative solution.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: how to find hash keys in a string ?
by Dr. Mu (Hermit) on May 04, 2003 at 07:59 UTC |