Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Is a integer or string.

by irah (Pilgrim)
on May 25, 2009 at 10:36 UTC ( [id://766007]=note: print w/replies, xml ) Need Help??


in reply to Is a integer or string.

There is no difference in Perl scalar variable in case of string and integer. If the value of the variable have only numbers, it treat as integer and it required "==" for comparison. If any alphabets available in variable, it treat as, string.

Is there any case where it fails?

In all places, the second condition will work.

From perlintro man page,

Scalar values can be strings, integers or floating point numbers, and Perl will automatically convert between them as required.

Replies are listed 'Best First'.
Re^2: Is a integer or string.
by akho (Hermit) on May 25, 2009 at 13:22 UTC
    perl -e "print 'Think again.' if ('1' == '1.0') && !('1' eq '1.0')"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found