Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Odd and even table rows

by Moron (Curate)
on Aug 09, 2007 at 09:54 UTC ( #631506=note: print w/replies, xml ) Need Help??


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!

.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://631506]
help
Chatterbox?
[stevieb]: I stated I use IDEA for Perl work, and at work, licensed version of PyCharm
[beech]: is that a good thing?
[stevieb]: absolutely. Free professional IDEs and related software for all the langs I write in, and I wanted CLion because it's a C IDE that can communicate directly with an Arduino

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2017-02-20 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (302 votes). Check out past polls.