Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case sensetivity

Status
Not open for further replies.

qwicker

Programmer
Feb 16, 2005
12
0
0
US
how can i do an if statement to compare to variables, regardless of their case sensetivity.
Lets say i have $a = ABC and $b = Abc. I want a value of true that $a==$b
 
if (lc($a) eq lc($b) ) {
do somthing
}

note == is for numeric comparison not string
 
the easiest way is the force the value to either all caps or lowercase letters, but that may not be the baest way if you need the data to remain in its current condition.


$a =~ tr/a-z/A-Z/; #change all letters to CAPS
$a =~ tr/A-Z/a-z/; #change all letters to lower case


HTH - Stiddy
 
the easiest way? I would think using uc() or lc() would be the easiest. Maybe not...
 
thanks, i just did $abs = "\L$abs\E";
 
if that's what you're doing, surely [tt]$abs = lc($abs);[/tt] is better on all fronts

- Andrew
Text::Highlight - A language-neutral syntax highlighting module in Perl
also on SourceForge including demo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top