The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Getopt::Gen - extended module for gengetopt-like parsing.

SYNOPSIS

 use Getopt::Gen;

 $og = Getopt::Gen->new({...});                # create a new object

 $og->parse($filename);                        # parse a program specification file
 $og->parse(\*HANDLE);                         # ... or a filehandle

 $og->fill_in(TYPE=>'FILE',SOURCE=>$filename); # Fill in a Text::Template skeleton
                                               # + You don't need 'TYPE' and 'SOURCE'
                                               #   arguments if you use a subclass
                                               #   such as Getopt::Gen::cmdline_h.

DESCRIPTION

Parse extended 'gengetopt'-style option files, and fill in output templates based on the parsed values.

PACKAGE VARIABLES

  • %DEFAULT_TEMPLATE_ARGS

    Default arguments for creating a new Text::Template object.

METHODS

Constructor

  • new(%args)

    Creates a new Getopt::Gen object based on keyword-arguments %args.

    Available keywords:

         ## -- basic data
         name=> __PACKAGE__ ,               # name to use for error-reporting
    
         ## -- generation-flags
         filename=>'cmdline',               # basename of output file
         funcname=>'cmdline_parser',        # name of parsing-function
         structname=>'gengetopt_args_info', # name of parser-structure
         longhelp=>0,                       # long usage line in help ?
         unnamed=>0,                        # allow non-option arguments ?
         reparse_action=>'error',           # when an option is re-given: error|warn|clobber
         handle_help=>1,                    # whether to handle '-h' and '--help' options
         handle_version=>1,                 # whether to handle '-V' and '--version' options
         handle_error=>1,                   # whether to exit on errors

Parsing Methods

  • parse_options($file)

    Parses an option-specification file. $file may be either a filename or an open filehandle. See optgen.perl for details on the file format.

Generation Methods

  • $og->fill_in(\%args)

    Generate a source file based on a skeleton using Text::Template. \%args may be used to override the default values for the Text::Template::new() and/or fill_in() methods.

BUGS

Probably many.

ACKNOWLEDGEMENTS

perl by Larry Wall.

'gengetopt' was originally written by Roberto Arturo Tena Sanchez, and it is currently maintained by Lorenzo Bettini.

AUTHOR

Bryan Jurish <moocow@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2003-2016 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.

SEE ALSO

Getopt::Gen::cmdline_pod(3pm), Getopt::Gen::cmdline_h(3pm), Getopt::Gen::cmdline_c(3pm), Getopt::Gen::Parser(3pm), Text::Template(3pm), perl(1).