Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: substituting values in an array

by Laurent_R (Abbot)
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?
Username:
Password:

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

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











    Results (340 votes). Check out past polls.