Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# Tie::Hash::NamedCapture

Perl 5 version 10.1 documentation
Go to top • Show page index • Download PDF

# Tie::Hash::NamedCapture

- NAME
- SYNOPSIS
- DESCRIPTION
- SEE ALSO

# NAME

Tie::Hash::NamedCapture - Named regexp capture buffers

# 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 %-

# DESCRIPTION

This module is used to implement the special hashes `%+` and `%-` , but it can be used to tie other variables as you choose.

When the `all` parameter is provided, then the tied hash elements will be 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, then the tied hash elements will be the contents of the leftmost defined buffer with the name of the associated hash key. In other words, the tied hash will behave 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).

# SEE ALSO

perlreapi, re, "Pragmatic Modules" in perlmodlib, "%+" in perlvar, "%-" in perlvar.

Page index

- NAME
- SYNOPSIS
- DESCRIPTION
- SEE ALSO

Recently read

Tools

- Preferences