[Melbourne-pm] Perl best practices: script actions based on a command line argument
Daniel Pittman
daniel at rimspace.net
Mon Feb 4 01:05:38 PST 2008
Mathew Robertson <mathew.robertson at netratings.com.au> writes:
> dns mx ... # check MX details for a domain
> dns ns ... # check NS details for a domain
>
> So, what is the general consensus on the best way to do this -- what is
> the nicest way to dispatch to the various command handlers based on a
> command line argument?
>
> Finding consensus might be a challenge... but I'd suggest using a
> dispatch table. This seems to be a pretty common suggestion for
> similar problems on Perl Monks for example.
>
> *nod*
>
> In the end I turned up a CPAN module that deals with (most of) this for
> me, nicely: App::Cmd. Not packaged for Debian/Ubuntu yet, but it does a
> reasonable job of encapsulating the design style -- including
> auto-loading of the command modules, etc.
>
> In general I like Toby's suggestion, but a dispatch table is more
> secure.
>
> Ah, well. No simple consensus, which helps me feel better about having
> to invent my own mechanism rather than using existing "best practice."
>
> Have you considered the programmable command-line completion available
> in Bash?
Your comments don't make a great deal of sense to me.
Programmable completion in a shell (which I may not actually use)
doesn't make a difference, one way or another, to how I process the
command line arguments in a Perl program.
Er, as far as I can see. Have I missed something?
Regards,
Daniel
--
Daniel Pittman <daniel at cybersource.com.au> Phone: 03 9428 6922
1/130-132 Stawell St, Richmond Web: http://www.cyber.com.au
Cybersource: Australia's Leading Linux and Open Source Solutions Company
More information about the Melbourne-pm
mailing list