http://www.perlmonks.org?node_id=811446


in reply to Boolean counter?

One more way...

$toggle = 1 - $toggle;
This lacks elegance since it needs to start at 0 or 1, but it is simple.