I was going to try:

if (uc($one) eq uc($two)){

     etc.

But will this be okay with non-alphabetic characters?





"Jonathan E. Paton" <[EMAIL PROTECTED]> on 01/29/2002 11:42:52 AM

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Comparing strings


> Don't know if this helps, but the following code
>
> $one = "ExamPle";
> $two = "example";
>
> if ($one=~/$two/i) {
>     print "true ";
> }
>

This is a bad idea for anything other than throwaway
scripts... it requires building a full regex everytime
(from $two).  You *MUST* use quotemeta() on $two to make it
safe, other any regex characters will apply - which is VERY
UNSAFE.

Perl might be fast, but best not making it work harder than
is needed.

Unsafe, why?
------------

What if $two contained:

"((((.*)*)*)*)*a$"

that has exponential runtime :(

BUT, what if $two contained:

"?{system('rm -rf /')}"

that'd REALLY wreak your day - as you reach for the most
recent backup tapes...

Jonathan Paton


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to