The first proposed solution:

if ($x =~ /$y/i)

is not remotely the same as the 'eq' solution.

$x = 'OkOk';
$y = 'ok';

This will match and clearly they are not the same. A better one would be:

if ($x =~ /^$y$/)

But even this has its problems,

$x = 'ok';
$y = '(ok|notok)';

Will still match, but are clearly not equal.  Really comes down to the sanity of your 
environment, but I would stick with the 'lc' proposed solution.

http://danconia.org



------------------------------------------------
On Tue, 3 Dec 2002 13:41:03 -0000, "Rob Dixon" <[EMAIL PROTECTED]> wrote:

> That would work fine, or you could change both to the same case for the
> duration of the comparison:
> 
>     if ( "\U$x" eq "\U$y" )
> 
> Rob
> 
> 
> ----- Original Message -----
> From: "Dylan Boudreau" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, December 03, 2002 1:30 PM
> Subject: RE: Case Insensitive
> 
> 
> > 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
> >
> > -----Original Message-----
> > From: SATAR VAFAPOOR [mailto:[EMAIL PROTECTED]]
> > Sent: December 3, 2002 9:27 AM
> > To: [EMAIL PROTECTED]
> > Subject: Case Insensitive
> >
> >
> >
> > Hello all,
> >
> > I want to make comaprisons in an if statement without caring about upper
> > or lower case eg $x='T'; $y='t'  if($x eq $y). can the i that is used in
> > regex be used here or is there another way. Thanks
> >
> > Sattar
> >
> 
> 
> 
> -- 
> 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