NAME

Getopt::ExPar - Extended Parameters command line parser.

SYNOPSIS

use Getopt::ExPar;
my($opt) = new Getopt::ExPar();

ABSTRACT

Method-based command line argument parser.

DESCRIPTION

This is a method-based command line argument handling package. ExPar was originally based on EvaP but was eventually rewritten from scratch. I have tested it and refined it over the course of around 6 years. I have been using it for internal projects for several years and now it is time to release it.

Introduction

Because of the near-infinite combinations of command line arguments, this package may seem burdensome to use. I hope that is not the case. In fact, I hope that its feature set will prove invaluable.

ooRoutines (method _ooRoutines) Very useful and possibly dangerous option. This creates OO methods named after your command line options. If you use more than one ExPar object in the same script, this could get tricky. Also, there are some Perl calls that you cannot duplicate: BEGIN, END, BLOCK, others? Also, if you happen to name one of your options the same as an internally-used routine, this could cause issues, but all the internal routines start with '_' so this can be easily avoided.

development_check (method _development_check) Set this to a 1 while you are developing your script. This does some checking to make sure there are no duplicate names used, etc.

abbreviations (method _abbreviations) Simply put, this allows the user to use an option only by specifying beginning of the option with enough characters to make it identifiable. For instance, if you have -xyz and -xvii options, the user could specify -xy or -xv but -x would give an error.

filelistpref (method _filelistpref) This determines how extra arguments are handled. Possible values are -1, 1, 0. -1 is default and means no files are expected. 0 means that files may be present. 1 means files must be present. By default, if 0 or 1 is used, any argument not found to be a match for a known option is considered the start of the filelist and all other options are considered files. So, it is possible for a user to give a bad option and the script to take it as the start of the fileilst.

intermingledFiles (method _intermingledFiles) This gives the option to allow files to be anywhere in the arguments. Any argument that does not match a specified option is added to the filelist. This overrides the aforementioned behavior of filelistpref and does not take the first non-matching parameter as the start of the file list.

switchglomming (method _switchglomming) This allows a group of switches to be specified as the first argument. For instance, if you have -x -y -z -p -d & -q switches, then the user can specify them in a single argument but it b<must> be the first argument: UNIX> script.pl -xyzpdq There is an exception. If the particular combinations of switches actually spells out another option or abbreviation or alias thereof, the switchglom will take precedence. This may or may not be what the user is expecting. Using the development_check preference can help alleviate this.

Methods

The 3 types of methods that deal with parameters are those that define, parse and access the command line data.

Defining Methods

_parameter (_p)

The main method for defining parameters. It can be called in several ways, but the primary way is:

_argl

_arglprepare

_argh

Routine to return all values as a HASH ref for specified parameter. Hash keys are numeric preserving order of parameters. If multi_parameter, returns all args as hash of hashes where subhashes are name/value pairs.

_filelist

Routine to return filelist if one exists.

EXAMPLE

PLANNED FEATURES

Here are a few ideas for future enhancements. Currently, there is no support for platforms other than UNIX and no support for languages other than Perl. (What else could there be...:)

Command Parameter Completion

Some shells in UNIX allow for command completion where the first few letters of a command is typed in and a completion-key, usually ESC or TAB, is pressed and the shell determines if enough letters have been typed to distinguish from any other command. Some shells allow a refinement of this by completing command parameters. In tcsh, this is done with the complete command. For programs with a complex option set, the complete command can become unmanagable.

Perhaps by calling the perl script with a -complete (--complete) option only, a complete definition would be printed to STDOUT.

POSSIBLE FEATURES

User Requests

I will entertain any [sane] ideas that users may have...:)

NOTES

This is currently Release 1.00. There are undoubtedly bugs and shortcomings. Please email me at harlinh@cadence.com with questions, comments, feature requests and bug reports.

VERSION HISTORY

1.00

Full initial release.

1.01

Repackaging of tar file.

AUTHOR

Harlin L. Hamilton Jr., <harlinh@cadence.com>

COPYRIGHT AND LICENSE

Copyright (C) 1998-2008 Harlin L. Hamilton Jr. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Module Install Instructions

To install Getopt::ExPar, simply copy and paste either of the commands in to your terminal