Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Answer: How do I compare two strings?

( #21412=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > How do I compare two strings? contributed by PipTigger

As an addendum to turnstep's fine post: Another useful test is: ne ... as in:
if ($string1 ne $string2) { print "\$string1 is not equal to \$string2\n"; }

Just as: == tests equality between two numbers,
!= tests inequality for numbers and
eq tests strings for equality as
ne tests strings for inequality.
I often find it useful to test
if ($string0 ne "") { #use $string0 }
to verify that a string has a value even if it's == 0.

Comment on Answer: How do I compare two strings?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2015-07-08 03:02 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 (93 votes), past polls