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

Re: Flag variables

by robartes (Priest)
on Mar 03, 2003 at 10:57 UTC ( #239996=note: print w/replies, xml ) Need Help??


in reply to Flag variables

I would say it detracts from code clarity and locality (sp?): your someaction depends on some other piece of code (the conditional setting of $flag) which could be several lines away. If all you want to do is someaction, the $flag is totally superfluous - just do the action directly:
foreach my $var (@somearray){ if($var eq "foo"){ someaction(); last;} }
More learned minds than mine will undoubtedly come up with other reasons why flag variables are often "bad".

CU
Robartes-

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2021-06-24 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (125 votes). Check out past polls.

    Notices?