in reply to Best way to handle 'commands'

Best way is to use Getopt::Long !

update: FoxtrotUniform has a point here. Getopt forces you to accept some conventions. Using Getopt is actually a matter of taste.

Replies are listed 'Best First'.
Re(2): Best way to handle 'commands'
by FoxtrotUniform (Prior) on Sep 19, 2002 at 15:20 UTC

    Why? It's not as if the OP has a lot of options handling to do. For one thing, (for example) apachectl restart is just as nice as (if not nicer than) apachectl --restart, and from the programmer's perspective:

    for my $cmd (@ARGV) { &{$dispatch->{$cmd}} or warn "Unrecognized command $cmd!\n"; }

    is about as good as:

    for my $cmd (keys %$opts) { &{$dispatch->{$cmd}} or warn "Unrecognized command $cmd!\n"; }

    In this context, what advantages do the Getopt modules have?

    --
    F o x t r o t U n i f o r m
    Found a typo in this node? /msg me
    The hell with paco, vote for Erudil!