No such thing as a small change | |
PerlMonks |
Re: Re: Re: Complex dispatch tableby dash2 (Hermit) |
on Feb 20, 2003 at 11:29 UTC ( [id://237050]=note: print w/replies, xml ) | Need Help?? |
I don't know if you can use Getopts modules on a string, but I bet there's an option somewhere. Take a look. Semantics means "meaning", more or less. The semantics of a statement are going to be what it actually does. The syntax is just how the statement is structured. So you have to think about how the commands you are using are related. Perhaps some commands have a context (a "state"). Some commands might be "like" others (so you can use inheritance to specify their semantics: derive behaviour from a base class, modify it in the child class). Et cetera. At the moment, you are basically assuming "all commands are semantically different" - they each get their own subroutine or module method call. You're also assuming "all commands are syntactically the same", but only in that they can be parsed by regexes. You could increase the level of syntactic sameness, and this might save you time typing out different regexes and format messages. Here's a rough example:
dave hj~
In Section
Seekers of Perl Wisdom
|
|