use Tie::FlipFlop; tie my $flipflop => Tie::FlipFlop => -1,1; print $flipflop for 1..10;