Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Answer: How do I compare two strings?

by PipTigger (Hermit)
on Jul 07, 2000 at 09:26 UTC ( #21412=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How do I compare two strings? - Answer 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and nobody stirs...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2017-03-25 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (311 votes). Check out past polls.