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

Re: Boolean counter?

by moritz (Cardinal)
on Dec 07, 2009 at 08:21 UTC ( #811449=note: print w/replies, xml ) Need Help??


in reply to Boolean counter?

You can just use ++ to increment your counter, but when you ask for its value use $counter % 2 instead of the counter itself.

Or if you're not interested in the numeric value 0, but rather that it's a false value, you can also use this update step:

$counter = !$counter;

Replies are listed 'Best First'.
Re^2: Boolean counter?
by JavaFan (Canon) on Dec 07, 2009 at 11:59 UTC
    Or if you do want the numerical value:
    $counter = !$counter || 0;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://811449]
help
Chatterbox?
[choroba]: BTW, both the bands I play in performed on Friday (at the same event). Quite an exhausting experience.
[Corion]: choroba: Ooof! I can imagine that ;)
[Corion]: I think at a Perl workshop some years ago I gave two talks on the same day and after that decided to only submit one talk per event ;)
[LanX]: you play the triangle, right?

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-03-27 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.