Perl GetOptions Subroutine
Jump to navigation
Jump to search
A Perl GetOptions Subroutine is a command-line argument processing Function for Perl programs.
- …
- Counter-Example(s):
- See: Command-line Option, Command-line Options Processor.
References
2015
- http://perldoc.perl.org/Getopt/Long.html
- QUOTE: The Getopt::Long module implements an extended getopt function called GetOptions(). It parses the command line from @ARGV , recognizing and removing specified options and their possible values.
This function adheres to the POSIX syntax for command line options, with GNU extensions. In general, this means that options have long names instead of single letters, and are introduced with a double dash "--". Support for bundling of command line options, as was the case with the more traditional single-letter approach, is provided but not enabled by default.
- QUOTE: The Getopt::Long module implements an extended getopt function called GetOptions(). It parses the command line from @ARGV , recognizing and removing specified options and their possible values.
2014
use Getopt::Std ; getopt('capdxkorhvfs', \%opts); $file = $opts{'f'} ? $opts{'f'} : "" ; $xfile = $opts{'x'} ? $opts{'x'} : "/tmp/filex.txt" use Getopt::Long; $data = "file.dat"; $length = 24; $result = GetOptions ("length=i" => \$length, # numeric "file=s" => \$data, # string "verbose" => \$verbose); # flag