™.. Class::MethodMaker::hash - Online Linux Manual PageSection : 3
Updated : 2014-05-22
Source : perl v5.10.1
Note : User Contributed Perl Documentation

NAMEClass::Method::hash − Create methods for handling a hash value.

SYNOPSIS​ use Class::MethodMaker ​ [ hash => [qw/ x /] ]; ​ ​ $instance−>x; # empty ​ $instance−>x(a => 1, b => 2, c => 3); ​ $instance−>x_count == 3; # true ​ $instance−>x = (b => 5, d => 8); # Note this *replaces* the hash, ​ # not adds to it ​ $instance−>x_index('b') == 5; # true ​ $instance−>x_exists('c'); # false ​ $instance−>x_exists('d'); # true

DESCRIPTIONCreates methods to handle hash values in an object. For a component named ​\*(C`x\*(C'\fR, by default creates methods \f(CW\*(C`x\*(C'\fR, \f(CW\*(C`x_reset\*(C'\fR, \f(CW\*(C`x_clear\*(C'\fR, \f(CW\*(C`x_isset\*(C'\fR, ​\*(C`x_count\*(C'\fR, \f(CW\*(C`x_index\*(C'\fR, \f(CW\*(C`x_keys\*(C'\fR, \f(CW\*(C`x_values\*(C'\fR, \f(CW\*(C`x_each\*(C'\fR, \f(CW\*(C`x_exists\*(C'\fR, ​\*(C`x_delete\*(C'\fR, \f(CW\*(C`x_set\*(C'\fR, \f(CW\*(C`x_get\*(C'\fR. Methods available are: \*(C`*\*(C'\fI\fR Created by default. This method returns the list of keys and values stored in the slot (they are returned pairwise, i.e., key, value, key, value; as with perl hashes, no order of keys is guaranteed). If any arguments are provided to this method, they replace the current hash contents. In an array context it returns the keys, values as an array and in a scalar context as a hash-reference. Note that this reference is no longer a direct reference to the storage, in contrast to Class::MethodMaker v1. This is to protect encapsulation. See x_ref if you need that functionality (and are prepared to take the associated risk.) If a single argument is provided that is an arrayref or hashref, it is expanded and its contents used in place of the existing contents. This is a more efficient passing mechanism for large numbers of values. *_reset Created by default. Called without an argument, this resets the component as a whole; deleting any associated storage, and returning the component to its default state. Normally, this means that *_isset will return false, and * will return undef. If \*(C`\-default\*(C'\fR is in effect, then the component will be set to the default value, and *_isset will return true. If ​\*(C`\-default_ctor\*(C'\fR is in effect, then the default subr will be invoked, and its return value used to set the value of the component, and *_isset will return true. If called with arguments, these arguments are treated as indexes into the component, and the individual elements thus referenced are reset (their storage deleted, so that *_isset(n) will return false for appropriate n, except where \*(C`\-default\*(C'\fR or \f(CW\*(C`\-default_ctor\*(C'\fR are in force, as above). As with perl arrays, resetting the highest set value implicitly decreases the count (but x_reset(n) never unsets the aggregate itself, even if all the elements are not set). *_clear Created by default. Empty the component of all elements, but without deleting the storage itself. If given a list of keys, then the elements that exist indexed by those keys are set to undef (but not deleted). Note the very different semantics: \*(C`$x\->a_clear(\*(Aqb\*(Aq)\*(C'\fR sets the value of ​\*(C`b\*(C'\fR in component 'a' to undef (if \f(CW\*(C`b\*(C'\fR) already exists (so \f(CW\*(C`$x\->a_isset(\*(Aqb\*(Aq))\*(C'\fR returns true), but \f(CW\*(C`$x\->a_clear()\*(C'\fR deletes the element \*(C`b\*(C'\fR from component 'a' (so \f(CW\*(C`$x\->a_isset(\*(Aqb\*(Aq))\*(C'\fR returns false). *_isset Created by default. Whether the component is currently set. This is different from being defined; initially, the component is not set (and if read, will return undef); it can be set to undef (which is a set value, which also returns undef). Having been set, the only way to unset the component is with *_reset. If a default value is in effect, then *_isset will always return true. *_isset() tests the component as a whole. *_isset(a) tests the element indexed by a. *_isset(a,b) tests the elements indexed by a, b, and returns the logical conjunction (and) of the tests. *_count Created by default. Returns the number of elements in this component. This is not affected by presence (or lack) of a \*(C`default\*(C'\fR (or ​\*(C`default_ctor\*(C'\fR). Returns \f(CW\*(C`undef\*(C'\fR if whole component not set (as per ​*_isset). *_index Created by default. Takes a list of indices, returns a list of the corresponding values. If a default (or a default ctor) is in force, then a lookup by index will vivify & set to the default the respective elements (and therefore the aggregate data-structure also, if it's not already). *_keys Created by default. The known keys, as a list in list context, as an arrayref in scalar context. If you're expecting a count of the keys in scalar context, see *_count. *_values Created by default. The known values, as a list in list context, as an arrayref in scalar context. *_each Created by default. The next pair of key, value (as a list) from the hash. *_exists Created by default. Takes any number of arguments, considers each as a key, and determines whether the key exists in the has. Returns the logical conjunction (and). *_delete Created by default. This operates exactly like *_reset, except that calling this with no args does nothing. This is provided for orthogonality with the Perl \*(C`delete\*(C'\fR operator, while \fI*_reset\fR is provided for orthogonality with other component types. *_set ​ %n = $x−>h; # (a=>1,b=>2,c=>3) (in some order) ​ $h−>h_set(b=>4,d=>7); ​ %n = $h−>a; # (a=>1,b=>4,c=>3,d=>7) (in some order) Created by default. Takes a list, treated as pairs of index => value; each given index is set to the corresponding value. No return. If two arguments are given, of which the first is an arrayref, then it is treated as a list of indices of which the second argument (which must also be an arrayref) are the corresponding values. Thus the following two commands are equivalent: ​ $x−>a_set(b=>4,d=>7); ​ $x−>a_set(['b','d'],[4,7]); *_get Created by default. Retrieves the value of the component without setting (ignores any arguments passed).
0
Johanes Gumabo
Data Size   :   24,309 byte
man-Class::MethodMaker::hash.3pmBuild   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   5 / 180,917
Visitor ID   :     :  
Visitor IP   :   52.14.219.203   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|Class::MethodMaker::hash.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|Class::MethodMaker::hash.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|Class::MethodMaker::hash.3pm|41|br══─}─══|'br══─}─══ )         (htmlprn|149|Class::MethodMaker::hash.3pm|41|'br══─}─══ |'br══─}─══ )         (rof_nr_x|149|Class::MethodMaker::hash.3pm|51/52|\nF|.ie \nF ══─{─══. de IX )         (rof_unit_scale_px|41|Class::MethodMaker::hash.3pm|51/52|F|.ie \nF ══─{─══. de IX )         (rof_if|19|Class::MethodMaker::hash.3pm|51/52|\nF|.ie \nF ══─{─══. de IX )         (htmlprn|149|Class::MethodMaker::hash.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2" )         (parse_manual_page_|249|Class::MethodMaker::hash.3pm|57|══─}─══|.══─}─══ )         (htmlprn|149|Class::MethodMaker::hash.3pm|57|.══─}─══ |.══─}─══ )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|152|\*(C`x\*(C'\fR, by default creates methods \f(CW\*(C`x\*(C'\fR, \f(CW\*(C`x_reset\*(C'\fR, \f(CW\*(C`x_clear\*(C'\fR, \f(CW\*(C`x_isset\*(C'\fR, |\&\f(CW\*(C`x\*(C'\fR, by default creates methods \f(CW\*(C`x\*(C'\fR, \f(CW\*(C`x_reset\*(C'\fR, \f(CW\*(C`x_clear\*(C'\fR, \f(CW\*(C`x_isset\*(C'\fR, )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|153|\*(C`x_count\*(C'\fR, \f(CW\*(C`x_index\*(C'\fR, \f(CW\*(C`x_keys\*(C'\fR, \f(CW\*(C`x_values\*(C'\fR, \f(CW\*(C`x_each\*(C'\fR, \f(CW\*(C`x_exists\*(C'\fR, |\&\f(CW\*(C`x_count\*(C'\fR, \f(CW\*(C`x_index\*(C'\fR, \f(CW\*(C`x_keys\*(C'\fR, \f(CW\*(C`x_values\*(C'\fR, \f(CW\*(C`x_each\*(C'\fR, \f(CW\*(C`x_exists\*(C'\fR, )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|154|\*(C`x_delete\*(C'\fR, \f(CW\*(C`x_set\*(C'\fR, \f(CW\*(C`x_get\*(C'\fR. |\&\f(CW\*(C`x_delete\*(C'\fR, \f(CW\*(C`x_set\*(C'\fR, \f(CW\*(C`x_get\*(C'\fR. )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|158|\*(C`*\*(C'\fI\fR |\fI\f(CI\*(C`*\*(C'\fI\fR )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|181|\*(C`\-default\*(C'\fR is in effect, then the component |and \fI*\fR will return undef. If \f(CW\*(C`\-default\*(C'\fR is in effect, then the component )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|183|\*(C`\-default_ctor\*(C'\fR is in effect, then the default subr will be invoked, and its |\&\f(CW\*(C`\-default_ctor\*(C'\fR is in effect, then the default subr will be invoked, and its )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|190|\*(C`\-default\*(C'\fR or \f(CW\*(C`\-default_ctor\*(C'\fR are in force, as above). As with |except where \f(CW\*(C`\-default\*(C'\fR or \f(CW\*(C`\-default_ctor\*(C'\fR are in force, as above). As with )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|204|\*(C`$x\->a_clear(\*(Aqb\*(Aq)\*(C'\fR sets the value of |Note the very different semantics: \f(CW\*(C`$x\->a_clear(\*(Aqb\*(Aq)\*(C'\fR sets the value of )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|205|\*(C`b\*(C'\fR in component 'a' to undef (if \f(CW\*(C`b\*(C'\fR) already exists (so \f(CW\*(C`$x\->a_isset(\*(Aqb\*(Aq))\*(C'\fR returns true), but \f(CW\*(C`$x\->a_clear()\*(C'\fR deletes the |\&\f(CW\*(C`b\*(C'\fR in component 'a' to undef (if \f(CW\*(C`b\*(C'\fR) already exists (so \f(CW\*(C`$x\->a_isset(\*(Aqb\*(Aq))\*(C'\fR returns true), but \f(CW\*(C`$x\->a_clear()\*(C'\fR deletes the )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|206|\*(C`b\*(C'\fR from component 'a' (so \f(CW\*(C`$x\->a_isset(\*(Aqb\*(Aq))\*(C'\fR returns false). |element \f(CW\*(C`b\*(C'\fR from component 'a' (so \f(CW\*(C`$x\->a_isset(\*(Aqb\*(Aq))\*(C'\fR returns false). )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|227|\*(C`default\*(C'\fR (or |This is not affected by presence (or lack) of a \f(CW\*(C`default\*(C'\fR (or )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|228|\*(C`default_ctor\*(C'\fR). Returns \f(CW\*(C`undef\*(C'\fR if whole component not set (as per |\&\f(CW\*(C`default_ctor\*(C'\fR). Returns \f(CW\*(C`undef\*(C'\fR if whole component not set (as per )         (rof_escape_sequence|91|Class::MethodMaker::hash.3pm|272|\*(C`delete\*(C'\fR operator, while \fI*_reset\fR is provided for |with the Perl \f(CW\*(C`delete\*(C'\fR operator, while \fI*_reset\fR is provided for )