[Melbourne-pm] Perl best practices: script actions based on a command line argument

Daniel Pittman daniel at rimspace.net
Sun Feb 3 17:39:08 PST 2008

Jacinta Richardson <jarich at perltraining.com.au> writes:
> Daniel Pittman wrote:
>>      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.


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

Ah, well.  No simple consensus, which helps me feel better about having
to invent my own mechanism rather than using existing "best practice."

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