Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: substituting values in an array

by Laurent_R (Canon)
on Jun 18, 2013 at 19:01 UTC ( #1039631=note: print w/replies, xml ) Need Help??

in reply to substituting values in an array

if ($array[$i] gt '200') { # ...

Good solutions have been provided to you, I would just like to point out to a severe error in your code that has not been picked up so far if I have read correctly.

If you want to compare numbers numerically (I mean arithmetical comparison), don't use the gt operator. If your array contains the element 1500, this will be deemed to be smaller than 200, because gt makes some form of lexical (or lexicographical, whatever) comparison (and 1 is smaller than 2). This is obviously not what you want. In brief, in such a case you want to use the > operator, rather than gt.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2018-02-24 01:00 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.