compare strings

D

DirkN

hi

I am comparing two string arrays, yet I get this warning:
Argument "sas " isn't numeric in numeric eq (==) at ./alljobs_read
line 22.

this is the code
if ("$user[$i]"=="$uniq[$j]") {..}

is there a different operator when comparing strings?

Dirk
 
C

cartercc

hi

I am comparing two string arrays, yet I get this warning:
Argument "sas     " isn't numeric in numeric eq (==) at ./alljobs_read
line 22.

this is the code
if ("$user[$i]"=="$uniq[$j]") {..}

is there a different operator when comparing strings?

Dirk

eq
 
A

Andrzej Adam Filip

DirkN said:
hi

I am comparing two string arrays, yet I get this warning:
Argument "sas " isn't numeric in numeric eq (==) at ./alljobs_read
line 22.

this is the code
if ("$user[$i]"=="$uniq[$j]") {..}

is there a different operator when comparing strings?

Dirk

if ($user[$i] eq $uniq[$j]) {..}
 
T

Tim Greer

DirkN said:
hi

I am comparing two string arrays, yet I get this warning:
Argument "sas " isn't numeric in numeric eq (==) at ./alljobs_read
line 22.

this is the code
if ("$user[$i]"=="$uniq[$j]") {..}

is there a different operator when comparing strings?

Dirk

== is only a numeric check and can have unexpected results unless you
know what it does and why. Use eq instead for non numeric checks.
 
T

Tad J McClellan

DirkN said:
hi

I am comparing two string arrays, yet I get this warning:
Argument "sas " isn't numeric in numeric eq (==) at ./alljobs_read
line 22.

this is the code
if ("$user[$i]"=="$uniq[$j]") {..}

is there a different operator when comparing strings?


Yes.
 
J

John Bokma

DirkN said:
hi

I am comparing two string arrays, yet I get this warning:
Argument "sas " isn't numeric in numeric eq (==) at ./alljobs_read
line 22.

this is the code
if ("$user[$i]"=="$uniq[$j]") {..}

Read

perldoc -q always

(What's wrong with always quoting "$vars")
is there a different operator when comparing strings?

Yes. I recommend to study

perldoc perlop

(section Relational Operators)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top