perldoc > Tie::SubstrHash

📖 NAME

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

🚀 Quick Reference

Use CaseCommandDescription
🔗 Tie a hash with fixed key and value lengths tie %myhash, 'Tie::SubstrHash', $key_len, $value_len, $table_size Creates a hash table with constant key size, value size, and table size
📦 Store a value $myhash{$key} = $value Requires $key exactly $key_len chars and $value exactly $value_len chars
🔍 Retrieve a value $val = $myhash{$key} Returns the stored value for the given key
⚠️ Memory efficient Uses much less internal memory than a free hash table

📋 SYNOPSIS

require Tie::SubstrHash;

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

📝 DESCRIPTION

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_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.

⚠️ 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.

The hash does not support exists().

Tie::SubstrHash
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION ⚠️ CAVEATS

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-21 16:13 @216.73.217.134
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!