Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Disadvantage of using 'eq' operator to compare numbers.

by ikegami (Pope)
on Jan 01, 2010 at 22:18 UTC ( #815233=note: print w/ replies, xml ) Need Help??


in reply to Disadvantage of using 'eq' operator to compare numbers.

If you want one to be equal to one, you want the numerical operators:

>perl -le"print 1 == '1.0' ?1:0" 1 >perl -le"print 1 eq '1.0' ?1:0" 0

If you want two to be less than ten, you want the numerical operators:

>perl -le"print 2 < 10 ?1:0" 1 >perl -le"print 2 lt 10 ?1:0" 0


Comment on Re: Disadvantage of using 'eq' operator to compare numbers.
Select or Download Code
Replies are listed 'Best First'.
Re^2: Disadvantage of using 'eq' operator to compare numbers.
by dsheroh (Parson) on Jan 02, 2010 at 14:01 UTC
    If you want two to be less than ten, you want the numerical operators:
    You've got a typo there... s/numerical/string/ (The examples still demonstrate it correctly.)

    The thinko was mine, not ikegami's. My comment was incorrect and adds nothing to the discussion; please reap.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2015-08-01 01: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 (285 votes), past polls