Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > compare strings

Reply
Thread Tools

compare strings

 
 
DirkN
Guest
Posts: n/a
 
      10-16-2008
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

 
Reply With Quote
 
 
 
 
cartercc
Guest
Posts: n/a
 
      10-16-2008
On Oct 16, 11:52*am, DirkN <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
Andrzej Adam Filip
Guest
Posts: n/a
 
      10-16-2008
DirkN <(E-Mail Removed)> wrote:

> 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]) {..}

--
[pl>en Andrew] Andrzej Adam Filip : http://www.velocityreviews.com/forums/(E-Mail Removed) : (E-Mail Removed)
Why won't you let me kiss you goodnight? Is it something I said?
-- Tom Ryan
 
Reply With Quote
 
Tim Greer
Guest
Posts: n/a
 
      10-16-2008
DirkN wrote:

> 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.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
 
Reply With Quote
 
Tad J McClellan
Guest
Posts: n/a
 
      10-16-2008
DirkN <(E-Mail Removed)> wrote:
> 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.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      10-16-2008
DirkN <(E-Mail Removed)> wrote:

> 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)

--
John http://johnbokma.com/ - Hacking & Hiking in Mexico

Perl help in exchange for a gift:
http://johnbokma.com/perl/help-in-ex...or-a-gift.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
Newbie: How to compare strings? =?Utf-8?B?Y2hhcmxpZXdlc3Q=?= ASP .Net 1 08-16-2005 09:44 PM
Re: Compare words (not Strings) mromarkhan@rogers.com Java 0 06-21-2004 12:56 AM
How to compare strings Thomas Reinemann VHDL 0 05-27-2004 02:24 PM
Compare strings al C++ 1 12-21-2003 02:16 AM



Advertisments