Gossamer Forum
Home : General : Perl Programming :

Okay. What am I missing here?

Quote Reply
Okay. What am I missing here?
How come this doesn't work?
Code:
if ($results =~ "?")
{
print "question mark";
}

And this doesn't work either:
Code:
if ($results =~ "\?")
{
print "question mark";
}

Any suggestions?

Thanks!




------------------
Complete Index of Web Master's Resources: http://www.cellwarp.com
Quote Reply
Re: Okay. What am I missing here? In reply to
Because quotes are not acceptable as delimiters in pattern matching. Plus, you do need to escape the ? since it has meaning in regex's.

This will work:

if ($results =~ /\?/) {
print "question mark";
}

--mark


------------------
Due to repeated requests for support via ICQ, I am once again offering support online.

The ONLY number I will accept requests on is #53788453. Messages sent to my other numbers will not pass through to me, as I have security settings set to ignore messages from users not on that list.

I don't know how often I will be active on this number, as it is for only when I am free to offer assistance.

Could this signature be any longer? :)