Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Update: Please use strict; ! Though I have not used this code, I have one comment to make in the spirit of TIMTOWTDI (hopefully a good comment) - I find the simulated switch statement to map a keypress to an action rather clumsy, as it does not really allow to easily add other actions later or add other actions dynamically. In such situations, I prefer to use a hash of code references, like this : and the routine interpretplay() would then look like this (sadly, untested) : or, if the whole state machine would be changed to use hashes, one could even use a single interpret() method that would simply look at the $current_state hash reference to find the action to be executed. Dynamically loaded actions would then simply modify the %actions hash with their entry. In reply to RE: cursebox v0.9 - switch{} coding style
by Corion
|
|