The xor operator will do what you want:

$counter = $counter xor 1

or

$counter ^= 1

(tested with perl -wle "print $counter ^=1 for 1..3")


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

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