Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Just another Perl shrine
 
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-


Comment on Re: Flag variables
Select or Download Code

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 scrutinizing the Monastery: (8)
As of 2014-04-20 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls