[Melbourne-pm] Command line argument processing with validation

Wesley Moore wjmoore at gmail.com
Wed Jun 27 17:04:11 PDT 2007


Hmm seems I got lost in there somewhere... The question should read:

I'm wondering if anyone knows of a module like Params::Validate that
would remove the second step by allowing required options be specified
as part of the option specification.

Wes

On 6/28/07, Wesley Moore <wjmoore at gmail.com> wrote:
> Hi all,
> In the system I work on we frequently create scripts to process a file
> from one format into another. All these scripts typically start off
> with something like:
>
> GetOptions(
>     'd|data_date=s' => \( my $DATA_DATE  = undef ),
>     'y|dict_root=s' => \( my $DICT_ROOT  = undef ),
>     'i|input=s'       => \( my $INPUTDIR  = undef ),
>     'o|output=s'    => \( my $OUTPUT     = undef ),
>     'v|verbose'     => \( my $VERBOSE    = undef ),
>     'h|help' => sub { pod2usage(1) },
>     'm|man'  => sub { pod2usage( -verbose => 2 ) },
> ) or pod2usage(2);
>
> if ( !defined $INPUT )     { pod2usage('No input dir specified') }
> if ( !defined $DATA_DATE )  { pod2usage('No -d <datadate> option specified') }
> if ( !defined $DICT_ROOT ) { pod2usage('No -y <dict_root> option specified') }
> if ( !defined $OUTPUT )    { pod2usage('No -o <output> option specified') }
>
> I'm wondering if anyone knows of a module like Params::Validate that
> would all the second step - validating required options were passed to
> be part of the option specification.
>
> Thanks,
> Wes
>


More information about the Melbourne-pm mailing list