Hash::...gs::V0(3pm)

πŸ“¦
version 1.18 Β· 2 versions
, in fedora 43

πŸ’– Hash::AutoHash::Args::V0 πŸ’–

okay bestie, so this is Hash::AutoHash::Args::V0 from the User Contributed Perl Documentation β€” it's the version-0 flavor of argument-list processing, and honestly? it's giving "the sequel that exists purely for the ex." 🫢

✨ VERSION ✨

Version 1.18. yes girl, 1.18. write it down. πŸ’…


🌸 SYNOPSIS 🌸

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

so you can grab stuff as hash elements, as methods, dump it all into locals, or alias it to a plain hash so your notation gets short and cute. pick your fighter. πŸ’–


πŸ‘‘ DESCRIPTION πŸ‘‘

This class simplifies the handling of keyword argument lists. Fr fr, that's the whole point of it. It replaces Class::AutoClass::Args, and it's a subclass of Hash::AutoHash::Args providing almost complete compatibility with Class::AutoClass::Arg. And here's the tea: the recommendation is that you use Hash::AutoHash::Args instead of this class, unless you actually need compatibility with Class::AutoClass::Args. like, this class is the one you date when you still live in the same town as your ex. 🫠

This class is identical to Hash::AutoHash::Args except as follows. Please refer to Hash::AutoHash::Args for the main documentation β€” that's where the real lore lives.

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. yep. that's the tradeoff, babes. In Hash::AutoHash::Args, these are provided as functions that can be imported in the caller's namespace, which avoids the masking problem entirely. ✨

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. convenient? yes. chaotic? also yes. πŸ’…

πŸŽ€ the methods, one by one πŸŽ€

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

πŸ¦‹ DIFFERENCES FROM Class::AutoClass::Args πŸ¦‹

This class differs from its precursor, Class::AutoClass::Args, only in a bug fix involving get_args in scalar context. one (1) difference. that's it. iconic minimalism. ⭐

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. embarrassing behavior honestly.

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. slay. πŸ’–

my $values=get_args($args,qw(name hobbies));  # now: gets ARRAY of both values

🌈 SEE ALSO 🌈

  • Hash::AutoHash::Args is the base class of this one. the parent, the blueprint, the blueprint-who-raised-you. 🫢
  • 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. the whole friend group fr fr. πŸ‘‘
  • perltie and Tie::Hash present background on tied hashes. if you wanna know how the magic works under the hood, go read those. 🧚

πŸ’œ AUTHOR πŸ’œ

Nat Goodman, "<natg at shore.net>". thank you nat, absolute legend. πŸ’…


πŸ’€ KNOWN BUGS AND CAVEATS πŸ’€

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. so like, the family drama belongs to the ancestor, not to us. πŸ’–

πŸ™ˆ Bugs, Caveats, and ToDos

See caveats about accessing arguments via method notation. that's the whole note. go look at the caveats. 🫠


🌸 SUPPORT 🌸

You can find documentation for this module with the perldoc command.

perldoc Hash::AutoHash::Args::V0

You can also look for information at:

  • RT: CPAN's request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hash-AutoHash-Args-V0>

  • AnnoCPAN: Annotated CPAN documentation

<http://annocpan.org/dist/Hash-AutoHash-Args-V0>

  • CPAN Ratings

<http://cpanratings.perl.org/d/Hash-AutoHash-Args-V0>

  • Search CPAN

<http://search.cpan.org/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.


and that's the whole page bestie, every flag, every note, every caveat, nothing skipped, no cap. πŸ’–

and finally, the lil sign-off: this whole thing is perl v5.42.0, dated 2025-07-25, and it's the Hash::...gs::V0 page β€” aka Hash::AutoHash::Args::V0(3pm). go forth and process those argument lists, queen. πŸ‘‘βœ¨πŸ’…πŸ¦‹πŸŒΈπŸ’–

πŸ“¦ where this page comes from