Tie::SubstrHash(3p) Perl Programmers Reference Guide Tie::SubstrHash(3p)

Tie::SubstrHash(3p) Perl Programmers Reference Guide Tie::SubstrHash(3p) #

Tie::SubstrHash(3p) Perl Programmers Reference Guide Tie::SubstrHash(3p)

NNAAMMEE #

 Tie::SubstrHash - Fixed-table-size, fixed-key-length hashing

SSYYNNOOPPSSIISS #

     require Tie::SubstrHash;

     tie %myhash, 'Tie::SubstrHash', $key_len, $value_len, $table_size;

DDEESSCCRRIIPPTTIIOONN #

 The TTiiee::::SSuubbssttrrHHaasshh package provides a hash-table-like interface to an
 array of determinate size, with constant key size and record size.

 Upon tying a new hash to this package, the developer must specify the
 size of the keys that will be used, the size of the value fields that the
 keys will index, and the size of the overall table (in terms of key-value
 pairs, not size in hard memory). _T_h_e_s_e _v_a_l_u_e_s _w_i_l_l _n_o_t _c_h_a_n_g_e _f_o_r _t_h_e
 _d_u_r_a_t_i_o_n _o_f _t_h_e _t_i_e_d _h_a_s_h. The newly-allocated hash table may now have
 data stored and retrieved. Efforts to store more than $table_size
 elements will result in a fatal error, as will efforts to store a value
 not exactly $value_len characters in length, or reference through a key
 not exactly $key_len characters in length. While these constraints may
 seem excessive, the result is a hash table using much less internal
 memory than an equivalent freely-allocated hash table.

CCAAVVEEAATTSS #

 Because the current implementation uses the table and key sizes for the
 hashing algorithm, there is no means by which to dynamically change the
 value of any of the initialization parameters.

 The hash does not support eexxiissttss(()).

perl v5.36.3 2023-02-15 Tie::SubstrHash(3p)