TIE::HASH::NAMEDCAPTURE(3perl)
๐ NAME ๐
Tie::Hash::NamedCapture โ named regexp capture buffers, bestie ๐
โจ SYNOPSIS โจ
tie my %hash, "Tie::Hash::NamedCapture";
# %hash now behaves like %+
tie my %hash, "Tie::Hash::NamedCapture", all => 1;
# %hash now access buffers from regexp in $qr like %-
Periodt. That's literally the whole vibe. ๐
๐ฆ DESCRIPTION ๐ฆ
okay so listen. This module is what's behind the curtain for the special hashes %+ and %-. That's its whole job, no cap. But โ and this is the fun part โ you're not locked into that, you can tie other variables with it if you want to, your choice, main character energy. ๐
Now here's the tea on the all parameter:
- When the
allparameter is provided, the tied hash elements are gonna be array refs, each one listing the contents of every capture buffer whose name matches the associated hash key. ๐ฎ If none of those buffers were actually involved in the match, then that array ref will hold as manyundefvalues as there are capture buffers with that name. Basically: the tied hash is giving%-. fr fr. - When
allis omitted or false, the tied hash elements are just the contents of the leftmost defined buffer with the name of the associated hash key. In other words, the tied hash is giving%+. ๐
And the key situation, because keys are a whole thing here:
- The keys of
%--like hashes correspond to all the buffer names found in the regular expression. All of them. - The keys of
%+-like hashes list only the names of the buffers that actually captured โ which means only the ones that got themselves associated with defined values. slay. โจ
๐ซถ heads up: this implementation has been moved into the core executable, but you can still load this module for backward compatibility. So like, it still works, it's fine, don't panic.
๐ SEE ALSO ๐
perlreapire- "Pragmatic Modules" in
perlmodlib "%+" in perlvar"%-" in perlvar
perl v5.44.0 ยท 2026-10-17 โ and that's the whole page, bestie. go tie some hashes, you ate that ๐ ๐ธ๐
๐ฆ 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