• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H18-Aug-2020-548209

lib/H18-Aug-2020-2,8751,217

t/H18-Aug-2020-337278

CHANGESH A D18-Aug-202021 KiB708464

INSTALLH A D07-Mar-20061.1 KiB3625

MANIFESTH A D18-Aug-20201.1 KiB2221

META.jsonH A D18-Aug-20201.1 KiB5049

META.ymlH A D18-Aug-2020656 2625

Makefile.PLH A D03-May-20223.1 KiB12394

READMEH A D18-Aug-20204.8 KiB13496

README

1Module Getopt::Long - extended processing of command line options
2=================================================================
3
4Module Getopt::Long implements an extended getopt function called
5GetOptions(). This function implements the POSIX standard for command
6line options, with GNU extensions, while still capable of handling
7the traditional one-letter options.
8In general, this means that command line options can have long names
9instead of single letters, and are introduced with a double dash `--'.
10
11Optionally, Getopt::Long can support the traditional bundling of
12single-letter command line options.
13
14Getopt::Long is part of the Perl 5 distribution. It is the successor
15of newgetopt.pl that came with Perl 4. It is fully upward compatible.
16In fact, the Perl 5 version of newgetopt.pl is just a wrapper around
17the module.
18
19For complete documentation, see "https://metacpan.org/release/Getopt-Long"
20or use the command
21
22    perldoc Getopt::Long
23
24FEATURES
25========
26
27* Long option names
28
29Major advantage of using long option names is that it is much easier
30to memorize the option names. Using single-letter names one quickly
31runs into the problem that there is no logical relationship between
32the semantics of the selected option and its option letter.
33Disadvantage is that it requires more typing. Getopt::Long provides
34for option name abbreviation, so option names may be abbreviated to
35uniqueness. Also, modern shells like Cornell's tcsh support option
36name completion. As a rule of thumb, you can use abbreviations freely
37while running commands interactively but always use the full names in
38scripts.
39
40Examples (POSIX):
41
42    --long --width=80 --height=24
43
44Extensions:
45
46    -long (convenience) +width=80 (deprecated) -height 24 (traditional)
47
48By default, long option names are case insensitive.
49
50* Single-letter options and bundling
51
52When single-letter options are requested, Getopt::Long allows the
53option names to be bundled, e.g. "-abc" is equivalent to "-a -b -c".
54In this case, long option names must be introduced with the POSIX "--"
55introducer.
56
57Examples:
58
59    -lgAd (bundle) -xw 80 (bundle, w takes a value) -xw80 (same)
60    even -l24w80 (l = 24 and w = 80)
61
62By default, single-letter option names are case sensitive.
63
64* Flexibility:
65
66  - Options can have alternative names, using an alternative name
67    will behave as if the primary name was used.
68  - Options can be negatable, e.g. "debug" will switch it on, while
69    "nodebug" will switch it off.
70  - Options can set values, but also add values producing an array
71    of values instead of a single scalar value, or set values in a hash.
72  - Options can have multiple values, e.g., "--position 25 624".
73
74* Options linkage
75
76Using Getopt::Long gives the programmer ultimate control over the
77command line options and how they must be handled:
78
79  - By setting a global variable in the calling program.
80  - By setting a specified variable.
81  - By entering the option name and the value in an associative array
82    (hash) or object (if it is a blessed hash).
83  - By calling a user-specified subroutine with the option name and
84    the value as arguments (for hash options: the name, key and value);
85  - Combinations of the above.
86
87* Customization:
88
89The module can be customized by specifying settings in the 'use'
90directive, or by calling a special method, Getopt::Long::Configure.
91For example, the following two cases are functionally equal:
92
93    use Getopt::Long qw(:config bundling no_ignore_case);
94
95and
96
97    use Getopt::Long;
98    Getopt::Long::Configure qw(bundling no_ignore_case);
99
100See the documentation for all possibilities.
101
102* Object oriented interface:
103
104Using the object oriented interface, multiple parser objects can be
105instantiated, each having their own configuration settings:
106
107    $p1 = new Getopt::Long::Parser (config => ["bundling"]);
108    $p2 = new Getopt::Long::Parser (config => ["posix"]);
109    if ($p1->getoptions(...options descriptions...)) ...
110
111AVAILABILITY
112============
113
114The official version for module Getopt::Long comes with the Perl 5
115distribution.
116Newer versions will be made available on the Comprehensive Perl Archive
117Network (CPAN), see "https://metacpan.org/release/Getopt-Long".
118
119COPYRIGHT AND DISCLAIMER
120========================
121
122Module Getopt::Long is Copyright 2013,1990 by Johan Vromans.
123This program is free software; you can redistribute it and/or
124modify it under the terms of the Perl Artistic License or the
125GNU General Public License as published by the Free Software
126Foundation; either version 2 of the License, or (at your option) any
127later version.
128
129-------------------------------------------------------------------
130Johan Vromans                                  jvromans@squirrel.nl
131Squirrel Consultancy                         Exloo, the Netherlands
132https://www.squirrel.nl                   https://johan.vromans.org
133------------------ "Arms are made for hugging" --------------------
134