Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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.

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://766005]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-06-23 13:18 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.