Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(elbie): Interpreting values alternately as $trings and Integers = confused response by Perl

by elbie (Deacon)
on Apr 14, 2002 at 20:07 UTC ( #158991=note: print w/ replies, xml ) Need Help??


in reply to Re: Interpreting values alternately as $trings and Integers = confused response by Perl
in thread Interpreting values alternately as $trings and Integers = confused response by Perl

Note that perl has two different kinds of comparison operators, one for strings (eq) and one for numerical values (==)

Minor point, but you should probably use $arr[0] == 12 to get a true numerical comparison. i.e. Drop the quotes.

elbieelbieelbie

  • Comment on (elbie): Interpreting values alternately as $trings and Integers = confused response by Perl
  • Download Code

Replies are listed 'Best First'.
Re: (elbie): Interpreting values alternately as $trings and Integers = confused response by Perl
by premchai21 (Curate) on Apr 15, 2002 at 01:09 UTC

    I agree that the quotes should probably be removed, but for reasons of clarity -- that is, people are likely to glance at the code and accidentally interpret the == as an eq due to seeing quotes. == does "true numerical comparison" whether or not there are quotes there; the string gets converted to a number for the ==, and it DWYM.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2016-06-29 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (379 votes). Check out past polls.