TIE::HASH::NAMEDCAPTURE(3pm)
🌸 NAME 🌸
okay bestie, welcome to Tie::Hash::NamedCapture from the Perl Programmers Reference Guide — it’s literally “named regexp capture buffers” and it’s giving main-character utility 💅
✨ SYNOPSIS ✨
the quick-start vibe is right here, no cap:
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 %-
first one is your %+ era, second one with all => 1 is your %- era 🎀
💖 DESCRIPTION 💖
so this module is what implements the special hashes %+ and %-, but lowkey it can also be used to tie other variables as you choose. iconic behavior, honestly.
when the all parameter is provided, the tied hash elements become array refs listing the contents of each capture buffer whose name is the same as the associated hash key. if none of these buffers were involved in the match, the contents of that array ref will be as many undef values as there are capture buffers with that name. in other words: the tied hash will behave as %- ✨
when the all parameter is omitted or false, the tied hash elements are the contents of the leftmost defined buffer with the name of the associated hash key. in other words: the tied hash behaves as %+ 💖
the keys of %--like hashes correspond to all buffer names found in the regular expression. the keys of %+-like hashes list only the names of buffers that have captured (and that are thus associated to defined values). yep, that’s the distinction, periodt 🫶
and important lore: this implementation has been moved into the core executable, but you can still load this module for backward compatibility. so it’s still here for you, bestie 💀✨
🦋 SEE ALSO 🦋
perlreapire- “Pragmatic Modules” in
perlmodlib %+inperlvar%-inperlvar
signing off with the footer tea ☕: this page is from perl v5.42.3, dated 2026-11-03, and it’s Tie::Hash::NamedCapture(3pm) — slay, bye 💜🦋
📦 where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 · Artistic-1.0-Perl OR GPL-1.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms