searching lines case-insensitive

J

James Hunt

Is there a way to do a case-insensitive search? This is what I have so far
....
I know that what I currently have is case-sensitive.
if($paramAction eq "SEARCH") {
open(SEARCH,"$csvfile");
@lines = <SEARCH>;
close(SEARCH);

foreach $line_entry (@lines) {
if($line_entry =~ /$searchkey/) {
print "$line_entry <br>\n";
}
}
}

James
 
G

Gunnar Hjalmarsson

James said:
Is there a way to do a case-insensitive search?

You seem to be talking about a case-insensitive pattern match, and if
so, the answer is yes.
 
J

Jürgen Exner

James said:
Is there a way to do a case-insensitive search?

Please define "search"? Exact match of whole line? RE? Text::Approx? ...
This is what I have
so far ... [...]
if($line_entry =~ /$searchkey/) {

Ah, REs. Did you check the fine manual?
The very first modifier that is mentioned in "perldoc perlre" talks about
Do case-insensitive pattern matching.

Jue
 
R

raymond

$line_entry =~ /$searchkey/i

this do search for case-insensitive

more deatils about perl regular expression try "perldoc
perlrequick,"perldoc perlre" "perldoc -t perlretut"

Raymond Raj X
 
J

James Hunt

[snip]
Ah, REs. Did you check the fine manual?
The very first modifier that is mentioned in "perldoc perlre" talks about
Do case-insensitive pattern matching.

Jue



Perfect that's exactly what I needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top