Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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".


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://239996]
[erix]: the neighbours (a nat.hist. museum) have a narwhal skull with *2* tusks
[erix]: ( also: UniCorn Throne )
[zentara]: erix I hope both tusks pointed in the same direction :-)
LanX "♪..♫ Last night a DJ killed my wife ♪..♫ "
zentara...oO 1 more reason I prefer Perl to Python is I can't believe how long Python takes to compile, and you can't disable the myriad of tests
[LanX]: so that's where you've been the last two years? Compiling Python?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2017-03-30 16:43 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (361 votes). Check out past polls.