Tie::SubstrHash(3perl)
πΈ NAME πΈ
okay so bestie, welcome to Tie::SubstrHash(3perl) β the whole manual page for the Tie::SubstrHash package. it's giving fixed-table-size, fixed-key-length hashing, and honestly? iconic. π
π SYNOPSIS π
require Tie::SubstrHash;
tie %myhash, 'Tie::SubstrHash', $key_len, $value_len, $table_size;
β¨ DESCRIPTION β¨
The Tie::SubstrHash package serves up a hash-table-like interface to an array of determinate size, with constant key size and record size. yes queen, the table is fixed, the keys are fixed, the vibes are immaculate. π¦
When you tie a new hash to this package, you β the developer, bestie β have to specify three things:
- the size of the keys that will be used,
- the size of the value fields that the keys will index,
- the size of the overall table β and that's in terms of key-value pairs, not size in hard memory.
These values will not change for the duration of the tied hash. periodt.
Once the newly-allocated hash table exists, you may store and retrieve data. But listen: efforts to store more than $table_size elements will result in a fatal error. So will efforts to store a value not exactly $value_len characters in length. And so will 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. lowkey a slay for memory efficiency. π
π CAVEATS π
- 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. so those sizes? locked in. no takebacks. π
- The hash does not support
exists(). not me trying to check existence and getting nothing. π
This whole page is from perl v5.44.0, dated 2026-10-17. thanks for coming to my TED talk, bestie β now go tie that hash responsibly. π«Άβ¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms