Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 5th, 2012, 08:33 AM
csvraju1985 csvraju1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 11 csvraju1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 34 m 47 sec
Reputation Power: 0
Question String Compare

I have a string
$string1 = "4PL400".

Now i read a string from <STDIN>.....

now i can enter both 4pl400 and 4PL400.......the question is how do i compare the input to string1.

In clear words, the input is case insensitive....but the comparison has to be done..

Please help and advise

Thanks in advance

Reply With Quote
  #2  
Old December 5th, 2012, 08:59 AM
OmegaZero OmegaZero is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2007
Posts: 737 OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 13 m 32 sec
Reputation Power: 928
Use the "lc" operator to change both strings to the same case, then compare with "eq".
Comments on this post
Laurent_R agrees!
__________________
sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

Reply With Quote
  #3  
Old December 5th, 2012, 09:01 AM
csvraju1985 csvraju1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 11 csvraju1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 34 m 47 sec
Reputation Power: 0
Thanks Omegazero

Reply With Quote
  #4  
Old December 6th, 2012, 05:42 AM
winblows winblows is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 5 winblows User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 25 sec
Reputation Power: 0
Quote:
Originally Posted by csvraju1985
I have a string
$string1 = "4PL400".

Now i read a string from <STDIN>.....

now i can enter both 4pl400 and 4PL400.......the question is how do i compare the input to string1.

In clear words, the input is case insensitive....but the comparison has to be done..

Please help and advise

Thanks in advance


You do do a case insensitive regular expression match.

Code:
$string1 = "4PL400";

$string2 = "4pl400";

if ( $string2 =~ /^$string1$/i )
{
  print "Matched!\n";
}
else {
  print "No match :(\n";
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > String Compare

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap