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

Re: Boolean counter?

by ikegami (Pope)
on Dec 07, 2009 at 08:08 UTC( #811444=note: print w/replies, xml ) Need Help??


in reply to Boolean counter?

For starters,
if ($toggle) { $toggle = 0; } else { $toggle = 1; }

can be written as

$toggle = $toggle ? 0 : 1;

And if you wanted a bitwise toggle, you could do

$toggle ^= 1;

But you asked for boolean, so you want the even simpler:

$toggle = !$toggle;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2016-08-30 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (417 votes). Check out past polls.