http://qs321.pair.com?node_id=139287


in reply to Re^4: Command line tool coding style?
in thread Command line tool coding style?

I'd suggest moving the "use Getopt::Long" to the top part, since that's where you actually use the module, and giving the lower section a real package name ("package MyTool" or something). Then instead of this:
my $handler = can main "_$action";
you can have this: this:
my $handler = MyTool->can("_$action");
Easier to follow, in my opinion.

Incidentally, a nice way to code tools like this is to make a separate module that implements all of the real logic, and then a CLI wrapper that just calls that module's methods. Then you can easilly add a GUI, call it from CGI, etc.