From: david <[EMAIL PROTECTED]>
> Dylan Boudreau wrote:
> 
> > I could be wrong here as I am still pretty new to perl but couldn't
> > you just do it like this
> > 
> > if ($x =~ /$y/i)
> > 
> > Dylan
> > 
> 
> almost correct! :-) how about:
> 
> if($x =~ /^$y$/i)
> 
> your reg. only checks to see if $y is within $x, not equal.

Better, but still incorrect. What if the $y contains some characters 
special to regexps? (dots, asterisks, braces, pluses ...)

If you insist on a regexp:

        if($x =~ /^\Q$y\E$/i)

but the also proposed

        if( lc($x) eq lc($y))

is still safer.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


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

Reply via email to