home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book Home Programming PerlSearch this book

32.27. Getopt::Long

If your program says:

use Getopt::Long;
GetOptions("verbose"  => \$verbose,
           "debug"    => \$debug,
           "output=s" => \$output);
it can be called from the command line like this:
% prog --verbose more args here
% prog --debug more args here
% prog -v -d more args here
% prog --output=somefile more args here
% prog -o somefile more args here
The Getopt::Long module provides a GetOptions function to process command-line switches with long names. It includes support for things like abbreviating switches, typed arguments like Boolean or string or integer or float, array variables for repeating options, user-defined validation routines, POSIX-conforming versus FSF-style processing, case-insensitive options, and traditional bundling of short options--just to name a few out of its vast cornucopia of features. If this module is overkill, consider the more traditional Getopt::Std module described next. If this module is underkill, check out the CPAN module Getopt::Declare, which provides a more declarative syntax for option specification.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.