Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://811444]
[msh210]: probably whoever wrote that actually knows the truth
[shmem]: msh210: you can save the perlbug text in a file and send that via your mail agent of choice
[msh210]: hm, okay, I'll try, thanks
[shmem]: ...not as an attachment, it's probably better to c&p that into the mail body

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-04-24 12:49 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (439 votes). Check out past polls.