📄 changes
字号:
Changes in version 2.36-----------------------**************** WARNING -- EXPERIMENTAL CODE AHEAD ***************** Parsing options from an arbitrary array The entry point GetOptionsFromArray (exported on demand) can be used to parse command line options that are not passed in via @ARGV, but using an arbitrary array. use Getopt::Long qw(GetOptionsFromArray); $ret = GetOptionsFromArray(\@myopts, ...);* Parsing options from an arbitrary string The entry point GetOptionsFromString (exported on demand) can be used to parse command line options that are not passed in via @ARGV, but using an arbitrary string. use Getopt::Long qw(GetOptionsFromString); $ret = GetOptionsFromString($optstring, ...); Note that upon completion, no arguments may remain in the string. If arguments may remain, call it in list context: ($ret, $args) = GetOptionsFromString($optstring, ...); @$args will have the remaining arguments.**************** END EXPERIMENTAL CODE ***************** Number values for options may include underscores for readability (just like Perls numbers).* Bugfix for Ticket #19432 (found and fixed by khali).* Bugfix to make it cooperate with the bignum pragma. Thanks to Merijn and Yves.* Various small fixes to make the test suite run under 5.004_05.* More examples (skeletons).Changes in version 2.35-----------------------* long_prefix_pattern configuration variable. prefix_pattern has now been complemented by a new configuration option 'long_prefix_pattern' that allows the user to specify what prefix patterns should have long option style sematics applied. This will enable people to do things like foo.pl /option=value instead of forcing people to use the short option style foo.pl /option value This enhancement was suggested and implemented by Yves Orton.* Bugfix for Ticket #11377 (bug found and fixed by Ryan).* Bugfix for Ticket #12380.* Options can take multiple values at once. E.g., --coordinates 52.2 16.4 --rgbcolor 255 255 149 To handle the above command line, the following call to GetOptions can be used: GetOptions('coordinates=f{2}' => \@coor, 'rgbcolor=i{3}' => \@color); You can specify the minimum and maximum number of values desired. The syntax for this is similar to that of regular expression patterns: { min , max }. Changes in version 2.34-----------------------* Auto-vivification of array and hash refs If an option is specified to require an array or hash ref, and a scalar reference is passed, this is auto-vivified to array or hash ref. Example: @ARGV = qw(--foo=xx); GetOptions("foo=s@", \$var); # Now $var->[0] eq "xx"* Auto-supplied verbose and help options are no longer taken into account when determining option ambiguity. This eliminates the common problem that you suddenly get an ambiguous option warning when you have an option "verbose" and run your program with "-v".* Cosmetic changes in some error messages.Changes in version 2.33-----------------------The following new features are marked experimental. This means that ifyou are going to use them you _must_ watch out for the next release ofGetopt::Long to see if the API has changed.* Getopt::Long can automatically handle --version and --help options if the calling program did not specify a handler explicitly. Two configuration parameters have been added: 'auto_help' (or 'help') and 'auto_version' (or 'version'). If set, Getopt::Long will itself take care of --help and --version options. Otherwise, everything is exactly as it was before. The new features will be enabled by default for programs that explicitly require version 2.3203 or later. Getopt::Long uses module Pod::Usage to produce the help message from the SYNOPSIS section of the program's POD. Using a --help (or -?) command line option will write the SYNOPSIS section of the program's POD to STDOUT, and exit with status 0. However, an illegal option will produce the help text to STDERR, and exit with status 2. This is in accordance with current conventions.* Two subroutines can be exported on demand: - VersionMessage This subroutine prints the standard version message. - HelpMessage This subroutine prints the standard help message. Both subroutines take the same arguments as Pod::Usage::pod2usage, see its documentation for details. Example: use Getopt::Long 2.33 qw(GetOptions HelpMessage); GetOptions(...) or HelpMessage(2);* Subroutine Configure can now be exported on demand.* Negatable options (with "!") now also support the "no-" prefix. On request of Ed Avis.* Some fixes with hashes and bundling. Thanks to Anders Johnson and Andrei Gnepp. Mandatory/optional status for hash values is now effective. String valued options with no value now default to the empty string instead of 1 (one). NOTE: The hash options still remain more or less experimental.* Fix a pass_through bug where the options terminator (normally "--") was not passed through in @ARGV. Thanks to Philippe Verdret.* Add FAQ: I "use GetOpt::Long;" (Windows) and now it doesn't work.Changes in version 2.32-----------------------* Fix a bug where the initial value for a optional numeric argumentwas not used for value of a hash option.* Remove 5.005 thread safety code. Getopt::Long is completely threadsafe when using the 5.8 ithreads.Changes in version 2.31-----------------------* Fix a bug where calling the configure method on a Getopt::Long::Parser object would bail out with Undefined subroutine &Getopt::Long::Parser::Configure called at Getopt/Long.pm line 186.Changes in version 2.30-----------------------* Fix a problem where a 'die' from a 'warn' via a localized $SIG{__WARN__} was not properly propagated from a callback. Thanks to Diab Jerius.Changes in version 2.29-----------------------* Fix a problem where options were not recognized when both auto_abbrev and ignore_case were disabled. Thanks to Seth Robertson.* Remove Carp.Changes in version 2.28-----------------------* When an option is specified more than once, a warning is generated if perl is run with -w. This is a correction to 2.27, where it would unconditionally die. An example of duplicate specification is GetOptions('foo', 'foo'), but also GetOptions('foo=s', 'foo') and GetOptions('Foo', 'foo') (the latter only when ignore_case is in effect).Changes in version 2.27-----------------------* You can now specify integer options to take an optional argument. that defaults to a specific value. E.g., GetOptions('foo:5' => \$var) will allow $var to get the value 5 when no value was specified with the -foo option on the command line. Instead of a value, a '+' may be specified. E.g., GetOptions('foo:+' => \$var) will allow $var to be incremented when no value was specified with the -foo option on the command line.* Fix several problems with internal and external use of 'die' and signal handlers.* Fixed some bugs with subtle combinations of bundling_override and ignore_case.* A callback routine that is associated with a hash-valued option will now have both the hask key and the value passed. It used to get only the value passed.* Eliminated the use of autoloading. Autoloading kept generating problems during development, and when using perlcc.* Avoid errors on references when an option is found in error, e.g. GetOptions('fo$@#' => \$var). Thanks to Wolfgang Laun.* When an option is specified more than once, an error is now generated. E.g., GetOptions('foo', 'foo'). Thanks to Wolfgang Laun.* Lots of internal restructoring to make room for extensions.* Redesigned the regression tests.* Enhance the documentation to prevent common misunderstandings about single character options.Changes in version 2.26-----------------------* New option type: 'o'. It accepts all kinds of integral numbers in Perl style, including decimal (24), octal (012), hexadecimal (0x2f) and binary (0b1001).* Fix problem with getopt_compat not matching +foo=bar.* Remove $VERSION_STRING for production versions.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -