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

Version 1.16_01

use Hash::AutoHash::Args::V0;
my $args=new Hash::AutoHash::Args::V0(name=>'Joe',
HOBBIES=>'hiking',hobbies=>'cooking');
# access argument values as HASH elements
my $name=$args->{name};
my $hobbies=$args->{hobbies};
# access argument values via methods
my $name=$args->name;
my $hobbies=$args->hobbies;
# set local variables from argument values -- three equivalent ways
use Hash::AutoHash::Args qw(autoargs_get);
my($name,$hobbies)=@$args{qw(name hobbies)};
my($name,$hobbies)=autoargs_get($args,qw(name hobbies));
my($name,$hobbies)=$args->get_args(qw(name hobbies)));
# copy args into local hash
my %args=$args->getall_args
# alias $args to regular hash for more concise hash notation
use Hash::AutoHash::Args qw(autoargs_alias);
autoargs_alias($args,%args);
my($name,$hobbies)=@args{qw(name hobbies)}; # get argument values
$args{name}='Joseph'; # set argument value

This class simplifies the handling of keyword argument lists. It replaces Class::AutoClass::Args. It is a subclass of Hash::AutoHash::Args providing almost complete compatibility with Class::AutoClass::Arg. We recommend that you use Hash::AutoHash::Args instead of this class unless you need compatibility with Class::AutoClass::Args.
This class is identical to Hash::AutoHash::Args except as follows. Please refer to Hash::AutoHash::Args for the main documentation.
Unlike Hash::AutoHash::Args, this class defines several methods and functions in its own namespace.
get_args, getall_args, set_args, fix_args, _fix_args, fix_keyword, fix_keywords, is_keyword, is_positional
A consequence of these being defined in the class's namespace is that they "mask" keywords of the same name and prevent those keywords from being accessed using method notation. In Hash::AutoHash::Args, these are provided as functions that can be imported in the caller's namespace which avoids the masking problem.
get_args, getall_args, and set_args are methods that can be invoked on Hash::AutoHash::Args::V0 objects. Descriptions of these methods are below. The others are functions and operate the same way here as in Hash::AutoHash::Args except that they do not need to be imported before use.
Title : get_args
Usage : ($name,$hobbies)=$args->get_args(qw(-name hobbies))
Function: Get values for multiple keywords
Args : array or ARRAY of keywords
Returns : array or ARRAY of argument values
Note : provided in Hash::AutoHash::Args as importable function
Title : getall_args
Usage : %args=$args->getall_args;
Function: Get all keyword, value pairs
Args : none
Returns : hash or HASH of key=>value pairs.
Note : provided in Hash::AutoHash::Args as importable function
Title : set_args
Usage : $args->set_args
(name=>'Joe the Plumber',-first_name=>'Joe',-last_name=>'Plumber')
Function: Set multiple arguments in existing object
Args : parameter list in same format as for 'new'
Returns : nothing
Note : provided in Hash::AutoHash::Args as importable function

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

Hash::AutoHash::Args is the base class of this one. Class::AutoClass::Args is replaced by this class.
Hash::AutoHash provides the object wrapper used by this class. Hash::AutoHash::MultiValued, Hash::AutoHash::AVPairsSingle, Hash::AutoHash::AVPairsMulti, Hash::AutoHash::Record are other subclasses of Hash::AutoHash.
perltie and Tie::Hash present background on tied hashes.

Nat Goodman, <natg at shore.net>

CPAN reports that "Make test fails under Perl 5.6.2, FreeBSD 5.2.1." for the predecessor to this class, Class::AutoClass::Args. We are not aware of any bugs in this class.
See caveats about accessing arguments via method notation.

You can find documentation for this module with the perldoc command.
perldoc Hash::AutoHash::Args::V0
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hash-AutoHash-Args-V0

Copyright (c) 2008, 2009 Institute for Systems Biology (ISB). All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.