1Hash::AutoHash::Args::VU0s(e3r)Contributed Perl DocumentHaatsiho:n:AutoHash::Args::V0(3)
2
3
4

NAME

6       Hash::AutoHash::Args::V0 - Object-oriented processing of argument lists
7       (version 0)
8

VERSION

10       Version 1.18
11

SYNOPSIS

13         use Hash::AutoHash::Args::V0;
14         my $args=new Hash::AutoHash::Args::V0(name=>'Joe',
15                                             HOBBIES=>'hiking',hobbies=>'cooking');
16
17         # access argument values as HASH elements
18         my $name=$args->{name};
19         my $hobbies=$args->{hobbies};
20
21         # access argument values via methods
22         my $name=$args->name;
23         my $hobbies=$args->hobbies;
24
25         # set local variables from argument values -- three equivalent ways
26         use Hash::AutoHash::Args qw(autoargs_get);
27         my($name,$hobbies)=@$args{qw(name hobbies)};
28         my($name,$hobbies)=autoargs_get($args,qw(name hobbies));
29         my($name,$hobbies)=$args->get_args(qw(name hobbies)));
30
31         # copy args into local hash
32         my %args=$args->getall_args
33
34         # alias $args to regular hash for more concise hash notation
35         use Hash::AutoHash::Args qw(autoargs_alias);
36         autoargs_alias($args,%args);
37         my($name,$hobbies)=@args{qw(name hobbies)}; # get argument values
38         $args{name}='Joseph';                       # set argument value
39

DESCRIPTION

41       This class simplifies the handling of keyword argument lists. It
42       replaces Class::AutoClass::Args. It is a subclass of
43       Hash::AutoHash::Args providing almost complete compatibility with
44       Class::AutoClass::Arg. We recommend that you use Hash::AutoHash::Args
45       instead of this class unless you need compatibility with
46       Class::AutoClass::Args.
47
48       This class is identical to Hash::AutoHash::Args except as follows.
49       Please refer to Hash::AutoHash::Args for the main documentation.
50
51       Unlike Hash::AutoHash::Args, this class defines several methods and
52       functions in its own namespace.
53
54         get_args, getall_args, set_args, fix_args, _fix_args, fix_keyword,
55         fix_keywords, is_keyword, is_positional
56
57       A consequence of these being defined in the class's namespace is that
58       they "mask" keywords of the same name and prevent those keywords from
59       being accessed using method notation. In Hash::AutoHash::Args, these
60       are provided as functions that can be imported in the caller's
61       namespace which avoids the masking problem.
62
63       get_args, getall_args, and set_args are methods that can be invoked on
64       Hash::AutoHash::Args::V0 objects. Descriptions of these methods are
65       below.  The others are functions and operate the same way here as in
66       Hash::AutoHash::Args except that they do not need to be imported before
67       use.
68
69        Title   : get_args
70        Usage   : ($name,$hobbies)=$args->get_args(qw(-name hobbies))
71        Function: Get values for multiple keywords
72        Args    : array or ARRAY of keywords
73        Returns : array or ARRAY of argument values
74        Note    : provided in Hash::AutoHash::Args as importable function
75
76        Title   : getall_args
77        Usage   : %args=$args->getall_args;
78        Function: Get all keyword, value pairs
79        Args    : none
80        Returns : hash or HASH of key=>value pairs.
81        Note    : provided in Hash::AutoHash::Args as importable function
82
83        Title   : set_args
84        Usage   : $args->set_args
85                    (name=>'Joe the Plumber',-first_name=>'Joe',-last_name=>'Plumber')
86        Function: Set multiple arguments in existing object
87        Args    : parameter list in same format as for 'new'
88        Returns : nothing
89        Note    : provided in Hash::AutoHash::Args as importable function
90

DIFFERENCES FROM Class::AutoClass::Args

92       This class differs from its precursor, Class::AutoClass::Args, only in
93       a bug fix involving get_args in scalar context.
94
95       In scalar context, get_args is supposed to return an ARRAY of argument
96       values. Instead, in Class::AutoClass::Args, it returned the value of
97       the first argument.
98
99         my $values=$args->get_args(qw(name hobbies)); # old bug: gets value of 'name'
100
101       The bug has been fixed and it now returns an ARRAY of the requested
102       argument values.
103
104         my $values=get_args($args,qw(name hobbies));  # now: gets ARRAY of both values
105

SEE ALSO

107       Hash::AutoHash::Args is the base class of this one.
108       Class::AutoClass::Args is replaced by this class.
109
110       Hash::AutoHash provides the object wrapper used by this class.
111       Hash::AutoHash::MultiValued, Hash::AutoHash::AVPairsSingle,
112       Hash::AutoHash::AVPairsMulti, Hash::AutoHash::Record are other
113       subclasses of Hash::AutoHash.
114
115       perltie and Tie::Hash present background on tied hashes.
116

AUTHOR

118       Nat Goodman, "<natg at shore.net>"
119

KNOWN BUGS AND CAVEATS

121       CPAN reports that "Make test fails under Perl 5.6.2, FreeBSD 5.2.1."
122       for the predecessor to this class, Class::AutoClass::Args.  We are not
123       aware of any bugs in this class.
124
125   Bugs, Caveats, and ToDos
126       See caveats about accessing arguments via method notation.
127

SUPPORT

129       You can find documentation for this module with the perldoc command.
130
131           perldoc Hash::AutoHash::Args::V0
132
133       You can also look for information at:
134
135       •   RT: CPAN's request tracker
136
137           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hash-AutoHash-Args-V0>
138
139       •   AnnoCPAN: Annotated CPAN documentation
140
141           <http://annocpan.org/dist/Hash-AutoHash-Args-V0>
142
143       •   CPAN Ratings
144
145           <http://cpanratings.perl.org/d/Hash-AutoHash-Args-V0>
146
147       •   Search CPAN
148
149           <http://search.cpan.org/dist/Hash-AutoHash-Args-V0/>
150
152       Copyright (c) 2008, 2009 Institute for Systems Biology (ISB). All
153       Rights Reserved.
154
155       This program is free software; you can redistribute it and/or modify it
156       under the terms of either: the GNU General Public License as published
157       by the Free Software Foundation; or the Artistic License.
158
159       See http://dev.perl.org/licenses/ for more information.
160
161
162
163perl v5.32.1                      2021-01-27       Hash::AutoHash::Args::V0(3)
Impressum