Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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;


Comment on Re: Boolean counter?
Select or Download Code

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 drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-09-01 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (13 votes), past polls