Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: logical non-short-circuit operators

by december (Pilgrim)
on Nov 02, 2011 at 18:55 UTC ( #935471=note: print w/replies, xml ) Need Help??


in reply to Re: logical non-short-circuit operators
in thread logical non-short-circuit operators

You're right, of course. The reason I avoided the former approach was because I have a lot of similar statements and I was hoping to keep the assignments in the scope of the conditional so as not to pollute the namespace or by accident reuse an old variable.

  • Comment on Re^2: logical non-short-circuit operators

Replies are listed 'Best First'.
Re^3: logical non-short-circuit operators
by moritz (Cardinal) on Nov 03, 2011 at 09:19 UTC

    If you have many similar statements, maybe you could refactor them to use a table for the conditions and a loop (or so), or in some other way. Code duplication or near-duplication is usually a sign that you can do it better somehow.

    If you want to avoid the variables leaking out, you can just put another block around the whole thing (variable declarations and if block).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2023-03-22 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?