Solved

search for string

Posted on 2002-05-06
1
319 Views
Last Modified: 2010-03-05
Hi,

I'm storing names (fullname and synonym1) into a hash like below:

$MyHash{$Id} = {id => $Id, fullName => $FullName, synonym1 => $Synonym1};

How can I search whether a string is found in the fullname or synonym1 ?

Eg.

$String = "Bill"
if "Bill" exist in fullname or synonym1 return true

Thanks,
Nick

0
Comment
Question by:n_chai
1 Comment
 
LVL 4

Accepted Solution

by:
dda earned 100 total points
ID: 6991012
if (($MyHash{$id}->{fullName} =~ /$String/) or ($MyHash{$id}->{synonim1} =~ /$String/})) {
 # found
 ...
} else {
 # not found
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now