This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
API tests for pad_findmy_*()
[perl5.git] / ext / Tie-Hash-NamedCapture / NamedCapture.pm
CommitLineData
8cf6f931 1use strict;
80305961 2package Tie::Hash::NamedCapture;
3195cf34 3
f8088870
NC
4our $VERSION = "0.08";
5
8cf6f931 6require XSLoader;
4b5ae309 7XSLoader::load(); # This returns true, which makes require happy.
44a2ac75
YO
8
9__END__
10
11=head1 NAME
12
80305961 13Tie::Hash::NamedCapture - Named regexp capture buffers
44a2ac75
YO
14
15=head1 SYNOPSIS
16
80305961 17 tie my %hash, "Tie::Hash::NamedCapture";
3195cf34 18 # %hash now behaves like %+
44a2ac75 19
28d8d7f4 20 tie my %hash, "Tie::Hash::NamedCapture", all => 1;
3195cf34 21 # %hash now access buffers from regexp in $qr like %-
44a2ac75
YO
22
23=head1 DESCRIPTION
24
3195cf34 25This module is used to implement the special hashes C<%+> and C<%->, but it
28d8d7f4 26can be used to tie other variables as you choose.
44a2ac75 27
3195cf34
RGS
28When the C<all> parameter is provided, then the tied hash elements will be
29array refs listing the contents of each capture buffer whose name is the
30same as the associated hash key. If none of these buffers were involved in
31the match, the contents of that array ref will be as many C<undef> values
32as there are capture buffers with that name. In other words, the tied hash
9f8c97d1 33will behave as C<%->.
44a2ac75 34
3195cf34
RGS
35When the C<all> parameter is omitted or false, then the tied hash elements
36will be the contents of the leftmost defined buffer with the name of the
9f8c97d1
RGS
37associated hash key. In other words, the tied hash will behave as
38C<%+>.
44a2ac75 39
3195cf34
RGS
40The keys of C<%->-like hashes correspond to all buffer names found in the
41regular expression; the keys of C<%+>-like hashes list only the names of
42buffers that have captured (and that are thus associated to defined values).
44a2ac75 43
44a2ac75
YO
44=head1 SEE ALSO
45
192b9cd1
AB
46L<perlreapi>, L<re>, L<perlmodlib/Pragmatic Modules>, L<perlvar/"%+">,
47L<perlvar/"%-">.
44a2ac75
YO
48
49=cut