Two more approaches:

- Using hashes:

my %Next = ( 0 => 1, 1 => 0); my $Counter = 0; #... $Counter = $Next{$Counter};

- Decreasing instead of increasing:

$Counter = abs --$Counter;

In reply to Re: Boolean counter? by vitoco
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":