Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Is a integer or string.

by targetsmart (Curate)
on May 25, 2009 at 10:33 UTC ( #766005=note: print w/ replies, xml ) Need Help??


in reply to Is a integer or string.

characters enclosed in "" or '' make a string, numbers otherwise.(other types also exist, but in this case we take only these two)
a string as well used as a number in some cases, and a number can be used as a string in some cases.
in your example, you used ==, in that case, the $value1 and $value2 even though it is a string it will be converted to relevant numbers and then it will be compared.
in case of eq, there will only be string comparison even you compare numbers.
'use strict' pragma can warn/help in those scenarios where you do == on string, etc. but by default perl converts your values internally according to the operator or the area of use

so this is how perl works, the programmer in his design has to differentiate and do the code appropriately.


Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.


Comment on Re: Is a integer or string.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (17)
As of 2014-07-31 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (250 votes), past polls