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;

In reply to Re: Boolean counter? by ikegami
in thread Boolean counter? by DreamT

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":