For a script I am writing I have a need to have a command interpreter at a server so that it knows what I want to do. There are a whole swag of different things I'm wanting to tell it and all the commands have different formats and argument requirements etc.
i.e.I am getting a whole range commands now and the way I've delt with it is firstly using a switch that checks the first key word i.e. /^log/ and then farm them off to now overwieldly subroutines the are large combinations of if's and reg ex's to work out which particular command format was used.
I'm thinking there has to be a prettier way, I mean it all works...its just not....'nice'. Is there a module or similar that is designed for this purpose so that after defining acceptable log formats it auto throws the bads ones and can dump acceptable results to the correct subroutines?
How have others solved this problem? Would say having a hash of subroutines as keys and reg ex's as the values and searching them on input be better? I'm guessing that would make insertion of new commands easier than trawling through a huge subroutine for the right place to insert.
Any incite would be appreciated =)..
Regards Paul.In reply to command input processing by thekestrel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |