Name : perl-Hash-AutoHash-Args
| |
Version : 1.18
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp150.1.2
| Date : 2015-04-16 14:00:00
|
Group : Development/Libraries/Perl
| Source RPM : perl-Hash-AutoHash-Args-1.18-lp150.1.2.src.rpm
|
Size : 0.05 MB
| |
Packager : (none)
| |
Summary : Object-oriented processing of keyword-based argument lists
|
Description :
This class simplifies the handling of keyword argument lists. It replaces the Class::AutoClass::Args manpage. See the DIFFERENCES FROM Class::AutoClass::Args manpage for a discussion of what\'s new. See the Hash::AutoHash::Args::V0 manpage for a subclass which is more compatible with the original.
The \'new\' method accepts a list, ARRAY, or HASH of keyword=>value pairs, another Hash::AutoHash::Args object, or any object that can be coerced into a HASH . It normalizes the keywords to ignore case and leading dashes (\'-\'). The following keywords are all equivalent:
name, -name, -NAME, --NAME, Name, -Name
Arguments can be accessed using HASH or method notation; the following are equivalent (assuming the keyword \'name\' exists in $args).
my $name=$args->{name}; my $name=$args->name;
Arguments values can also be changed using either notation:
$args->{name}=\'Jonathan\'; $args->name(\'Jonathan\');
Keywords are normalized automatically; the following are all equivalent.
my $name=$args->{name}; # lower case HASH key my $name=$args->{Name}; # capitalized HASH key my $name=$args->{NAME}; # upper case HASH key my $name=$args->{NaMe}; # mixed case HASH key my $name=$args->{-name}; # leading - in HASH key
The following are also all equivalent, and are equivalent to the ones above assuming the keyword \'name\' exists in $args.
my $name=$args->name; # lower case method my $name=$args->Name; # capitalized method my $name=$args->NAME; # upper case method my $name=$args->NaMe; # mixed case method
One caution is that when using method notation, keywords must be syntactically legal method names and cannot include leading dashes. The following is NOT legal.
my $name=$args->-name; # leading dash in method - ILLEGAL
Repeated keyword arguments are converted into an ARRAY of the values.
new Hash::AutoHash::Args(hobbies=>\'hiking\', hobbies=>\'cooking\')
is equivalent to
new Hash::AutoHash::Args(hobbies=>[\'hiking\', \'cooking\'])
Caution: when setting values using HASH or method notation, the grouping of repeated arguments does NOT occur. Thus,
AATT$args{qw(hobbies hobbies)}=qw(running rowing);
leaves \'hobbies\' set to the last value presented, namely \'rowing\', as does
$args->hobbies(\'running\'); $args->hobbies(\'rowing\');
New keywords can be added using either notation. For example,
$args->{first_name}=\'Joe\'; $args->last_name(\'Plumber\');
If a keyword does not exist, the method notation returns nothing, while the HASH notation returns undef. This difference matters in array context (including when passing the result as a parameter).
my AATTlist=$args->non_existent; # AATTlist will contain 0 elements my AATTlist=$args->{non_existent}; # AATTlist will contain 1 element
We find the method behavior (returning nothing) to be more natural and is the behavior in Class::AutoClass::Args. Unfortunately, Perl does not support this behavior with HASH notation; if the tied hash code returns nothing, Perl converts this into undef before passing the result to the caller. Too bad.
You can alias the object to a regular hash for more concise hash notation.
use Hash::AutoHash::Args qw(autoargs_alias); autoargs_alias($args,%args); my($name,$hobbies)=AATTargs{qw(name hobbies)}; $args{name}=\'Joseph\';
By aliasing $args to %args, you avoid the need to dereference the variable when using hash notation. Admittedly, this is a minor convenience, but then again, this entire class is about convenience.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl/openSUSE_Leap_15.0/noarch |
Hmm ... It's impossible ;-) This RPM doesn't exist on any FTP server
Provides :
perl(Hash::AutoHash::Args)
perl(Hash::AutoHash::Args::V0)
perl(Hash::AutoHash::Args::V0::helper)
perl(Hash::AutoHash::Args::helper)
perl(Hash::AutoHash::Args::tie)
perl-Hash-AutoHash-Args
Requires :