NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
run method is ugly! (Score:2)
Your &run method if/elsif/else chain is very difficult to read. Switching to a dispatch table makes it much easier to understand.
Re: (Score:1)
Re:run method is ugly! (Score:2)
It's easier to see which action maps to which method and makes it less likely to have bugs in the future as adding a new action is trivial. You just add a new entry to the hash and don't have to worry about the code.
Reply to This
Parent
Re: (Score:1)
Re: (Score:1)
But you are right the if/else chain is VISUALLY hard to read, so I might do something to fix that instead of moving to dispatch table.
Re: (Score:1)
Technically that’s not even a dispatch table (since it does not map from strings to coderefs). I don’t know why people “need to read about them” either – I came up with the concept independently long before I knew it had a name. Seems obvious to me, and I don’t think I am a genius… what do I know.
And actually, I don’t know why Ovid rewrote the code the way he did, because it’s easy to make it even simpler: