Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: compare always true in grep

by crashtest (Curate)
on Oct 24, 2014 at 18:52 UTC ( [id://1104901]=note: print w/replies, xml ) Need Help??


in reply to compare always true in grep

My 5.18.2 on Linux dies the same way. B::Deparse shows this interpretation of your if statement:

if (grep((0 + $_ >= 99999999)), @times) {
Note the parentheses. That is, you have a scalar comma expression with the grep and the @times array, which evaluates to @times. The grep is evaluating the expression 0 + $_ >= 9999999 on an empty list, but that's irrelevant.

Adding the parentheses properly works:

if (grep (((0 + $_) >= 99999999), @times)) { ... # prints: Times: 1 2 3 4

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-24 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found