Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: How to match String with Case Sensitive??

by Sachin (Acolyte)
on Oct 30, 2009 at 12:27 UTC ( #804145=note: print w/ replies, xml ) Need Help??


in reply to Re^3: How to match String with Case Sensitive??
in thread How to match String with Case Sensitive??

I also tried with chomp($test1); and chop($test1); method. but it's not working..

#! /usr/bin/perl my $test = "abc"; my $test1 = <STDIN>; # Suppose test1 = "AbC" print $test1; chop($test1); if($test =~ m#$test1#){ print "\n Both are Same"; } else{ print "\n Both are not Same"; }


Comment on Re^4: How to match String with Case Sensitive??
Download Code
Re^5: How to match String with Case Sensitive??
by vitoco (Friar) on Oct 30, 2009 at 13:12 UTC

    Hey! You are trying to match a constant against a pattern got from an input string. Is that what you want? Then try what moritz suggested.

    If not, change to:

    if($test1 =~ m#$test#){

    But without i modifier, "abc" will never be the same as "AbC".

    Of course, to be "the same" instead of just "contains", use:

    if($test1 =~ m#^$test$#){

    or:

    if($test1 eq $test){

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://804145]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-07-07 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls