CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Searching a Hash

 



KaoAtlantis
Novice

Nov 23, 2000, 4:25 PM

Post #1 of 2 (178 views)
Searching a Hash Can't Post

I have a Quick (Maybe not so Simple Question).

I am wondering how to search for a word/sentance in a hash, so that if it finds the word/sentance it will return the hash KEY's to the user.

I have been having problems with this and hope someone can give me an Example to learn from.

Thanks for the help, Kao


japhy
Enthusiast

Nov 23, 2000, 7:45 PM

Post #2 of 2 (178 views)
Re: Searching a Hash [In reply to] Can't Post

This depends entirely on how your hash is set up. Are the values in the hash long paragraphs? If so, you might want to do something like:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


my @results;
while (my ($k,$v) = each %hash) {
push @results, $k if index($v,$sentence) > -1;
}
</pre><HR></BLOCKQUOTE>

------------------
Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives