ausag has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to figure out how to compare a value to certain characters within a word, using an if statement.
For example, let's say I have this:
$word = "bummer";
I want to check to see if the value of "mme" is == to the 3rd, 4th, and 5th characters of $word
I don't want to just grep "mme" out of a word (that would be easy). I want to specifically compare a value to the 3rd, 4th, and 5th characters of a word.
So that,
$word = "bummer";
$match = "mme";
if (insert code here == $match)
{
print "Gotta match\n";
}
else {print "No match\n";}
How do I go about doing that?
Thanks for your help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Character matching in a word?
by BrowserUk (Patriarch) on Sep 21, 2004 at 17:16 UTC | |
by ausag (Initiate) on Sep 21, 2004 at 17:40 UTC | |
|
Re: Character matching in a word?
by TedPride (Priest) on Sep 21, 2004 at 20:20 UTC | |
|
Re: Character matching in a word?
by graff (Chancellor) on Sep 22, 2004 at 03:25 UTC |