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


in reply to Odd and even table rows

My first thought was:
our $flipflop = !1; our %class = ( $flipflop => 'even', !$flipflop => 'odd' ); sub getclass { $class{ $flipflop = !$flipflop }; }
The '!' in the initialisation values are to avoid reliance on specific truth values so they can be used safely as hash keys for any given Perl implementation.

update: in practice I'd use an instance variable instead of a class variable for $flipflop, but before that I'd have to do OO makeover of the OP which I avoided doing.

__________________________________________________________________________________

^M Free your mind!

.