LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2009, 04:50 PM   #1
cmontr
Member
 
Registered: Sep 2007
Posts: 175

Rep: Reputation: 15
perl case sensitivity


Hi Guys,

When use this liner code, anyway to print "TeSt" in case insentive?

ie. it should print all "test, Test, TEST etc..."

Code:

perl -s -ne '($user,$ou) = /.*uid=(.*?), ou=(.*?),.*/ if /^dn/; print "$user\n" if /^stat: 2/ && $ou eq "test";' infile


Thanks
 
Old 10-09-2009, 06:51 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
please read perldoc perlre (from now on). There is a modifier to do case insensitivity in Perl's regex.
 
Old 10-09-2009, 07:35 PM   #3
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60
Instead of testing for string equality ($string eq 'test'), you should use a regular expression with the i flag.

Code:
telemachus ~ $ cat file 
test
TeSt
TEst
tesT
TEsT
TEST
gotcha
telemachus ~ $ perl -nle 'print if $_ =~ /test/i' file
test
TeSt
TEst
tesT
TEsT
TEST
See perldoc perlrequick for a good introduction to regular expressions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
case sensitivity newbiesforever Linux - General 2 02-26-2009 11:08 PM
Kerberos and case sensitivity chriscowley Linux - Networking 1 05-02-2008 09:53 AM
Apache case sensitivity problems VeeDubbs Linux - Networking 1 02-19-2006 06:00 PM
Case-Sensitivity in Python Odd_Bloke Programming 2 09-02-2003 04:20 PM
Case sensitivity in SED substitutions jkoch Programming 1 02-21-2003 04:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration