1AppConfig::Getopt(3) User Contributed Perl Documentation AppConfig::Getopt(3)
2
3
4
6 AppConfig::Getopt - Perl5 module for processing command line arguments
7 via delegation to Getopt::Long.
8
10 use AppConfig::Getopt;
11
12 my $state = AppConfig::State->new(\%cfg);
13 my $getopt = AppConfig::Getopt->new($state);
14
15 $getopt->parse(\@args); # read args
16
18 AppConfig::Getopt is a Perl5 module which delegates to Johan Vroman's
19 Getopt::Long module to parse command line arguments and update values
20 in an AppConfig::State object accordingly.
21
22 AppConfig::Getopt is distributed as part of the AppConfig bundle.
23
25 USING THE AppConfig::Getopt MODULE
26
27 To import and use the AppConfig::Getopt module the following line
28 should appear in your Perl script:
29
30 use AppConfig::Getopt;
31
32 AppConfig::Getopt is used automatically if you use the AppConfig module
33 and create an AppConfig::Getopt object through the getopt() method.
34
35 AppConfig::Getopt is implemented using object-oriented methods. A new
36 AppConfig::Getopt object is created and initialised using the new()
37 method. This returns a reference to a new AppConfig::Getopt object. A
38 reference to an AppConfig::State object should be passed in as the
39 first parameter:
40
41 my $state = AppConfig::State->new();
42 my $getopt = AppConfig::Getopt->new($state);
43
44 This will create and return a reference to a new AppConfig::Getopt
45 object.
46
47 PARSING COMMAND LINE ARGUMENTS
48
49 The "parse()" method is used to read a list of command line arguments
50 and update the state accordingly.
51
52 The first (non-list reference) parameters may contain a number of con‐
53 figuration strings to pass to Getopt::Long::Configure. A reference to
54 a list of arguments may additionally be passed or @ARGV is used by
55 default.
56
57 $getopt->parse(); # uses @ARGV
58 $getopt->parse(\@myargs);
59 $getopt->parse(qw(auto_abbrev debug)); # uses @ARGV
60 $getopt->parse(qw(debug), \@myargs);
61
62 See Getopt::Long for details of the configuartion options available.
63
64 A Getopt::Long specification string is constructed for each variable
65 defined in the AppConfig::State. This consists of the name, any
66 aliases and the ARGS value for the variable.
67
68 These specification string are then passed to Getopt::Long, the argu‐
69 ments are parsed and the values in the AppConfig::State updated.
70
71 See AppConfig for information about using the AppConfig::Getopt module
72 via the getopt() method.
73
75 Andy Wardley, <abw@wardley.org>
76
78 $Revision: 1.60 $
79
81 Copyright (C) 1997-2003 Andy Wardley. All Rights Reserved.
82
83 Copyright (C) 1997,1998 Canon Research Centre Europe Ltd.
84
85 This module is free software; you can redistribute it and/or modify it
86 under the same terms as Perl itself.
87
89 Many thanks are due to Johan Vromans for the Getopt::Long module. He
90 was kind enough to offer assistance and access to early releases of his
91 code to enable this module to be written.
92
94 AppConfig, AppConfig::State, AppConfig::Args, Getopt::Long
95
96
97
98perl v5.8.8 2007-01-02 AppConfig::Getopt(3)