Perl equivalent of mysql "like"

M

Manasa

Is there a Perl's equivalent of MySQL "like" operation?

I have to match names from the database in the same way as MySQL's
like operation without executing a mysql query.

I have tried Perl's String::Approx but even that does not completely
solve my problem.

This is what I want to do:

$name = "CIVITAF INCORPORATED";

And my hash has the following:

$hash->{"CIVITAF INC OF CALIFORNIA"} = "121212";

I want to do this

foreach $key (keys %{$hash}) {

if ($key like $name) {

....
.....
}
}

Any help would be appreciated.

Thanks,
Manasa
 
S

Skeleton Man

Is there a Perl's equivalent of MySQL "like" operation?
I have to match names from the database in the same way as MySQL's
like operation without executing a mysql query.

Use regular expressions. In the most basic form this check if $key contains
the contents of $name anywhere:
(Case insensitive)

if ($key =~ /$name/i) {
...
...
}


Regards,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top