13 Mar 2022 08:40:18 UTC
- Distribution: perl
- Module version: 1.00
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2152)
- KwaliteeBus factor: 15
- License: perl_5
- Activity24 month
- Download (17.35MB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:209 non-PAUSE usersSHAY Steve Hayand 1 contributors
Tie::SubstrHash - Fixed-table-size, fixed-key-length hashing
require Tie::SubstrHash; tie %myhash, 'Tie::SubstrHash', $key_len, $value_len, $table_size;
The Tie::SubstrHash 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). These values will not change for the duration of the tied hash. The newly-allocated hash table may now have data stored and retrieved. Efforts to store more than
$table_sizeelements will result in a fatal error, as will efforts to store a value not exactly
$value_lencharacters in length, or reference through a key not exactly
$key_lencharacters 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.
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 exists().