The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Getopt::Long::Spec::Builder - Build a Getopt::Long option spec from a set of attributes

VERSION

version 0.002

SYNOPSIS

This module builds a Getopt::Long option specification from a hash of option parameters as would be returned by Getopt::Long::Spec::Parser->parse($spec) and/or Getopt::Nearly::Everything->opt($opt_name)->attrs().

Here's an example of use:

use Getopt::Long::Spec::Builder;

my %opt_attrs = (
    opt_type       => 'simple'
    value_required => 1,
    value_type     => 'string',
    max_vals       => '5',
    dest_type      => 'array',
    min_vals       => '1',
    short          => [ 'f' ],
    long           => 'foo',
);

my $builder   = Getopt::Long::Spec::Builder->new();
my $spec      = $builder->build( %opt_attrs );
print $spec;  # output: 'foo|f=s@{1,5}'

# OR...

my $spec =
    Getopt::Long::Spec::Builder->build( %opt_attrs );

METHODS

new

Create a new builder object.

build

Build a Getopt::Long option specification from the attributes passed in and return the spec as a string

SEE ALSO

  • Getopt::Long - info on option specifications

  • Getopt::Long::Spec - parse and build GoL specifications

  • Getopt::Long::Spec::Parser - parse GoL specifications

  • Getopt::Nearly::Everything - the module for which this module was created

AUTHOR

Stephen R. Scaffidi <sscaffidi@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Stephen R. Scaffidi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.