Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Situation where warning "Found = in conditional, should be" seems obsolete

by choroba (Cardinal)
on Feb 06, 2021 at 09:59 UTC ( [id://11127971]=note: print w/replies, xml ) Need Help??


in reply to Situation where warning "Found = in conditional, should be" seems obsolete

Are you sure you want to execute last only when $has_even = 1 is true? Using "and" would be confusing if you decide later to refactor the code and suddenly end up with
$_ % 2 and $has_odd = 0 and last;
or maybe the second "and" would be turned to "or", but it would be confusing anyway.

More idiomatic way of writing this would be

$_ % 2 or $has_even = 1, last;
if you insisted on using no if/unless. I'd probably use
$has_even = 1, last unless $_ % 2;
but YMMV.

Update: s/if/unless/. Thanks Athanasius.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found