[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 package Tie::Hash::NamedCapture; 2 3 our $VERSION = "0.06"; 4 5 # The real meat implemented in XS in universal.c in the core, but this 6 # method was left behind because gv.c expects a Purl-Perl method in 7 # this package when it loads the tie magic for %+ and %- 8 9 my ($one, $all) = Tie::Hash::NamedCapture::flags(); 10 11 sub TIEHASH { 12 my ($pkg, %arg) = @_; 13 my $flag = $arg{all} ? $all : $one; 14 bless \$flag => $pkg; 15 } 16 17 tie %+, __PACKAGE__; 18 tie %-, __PACKAGE__, all => 1; 19 20 1; 21 22 __END__ 23 24 =head1 NAME 25 26 Tie::Hash::NamedCapture - Named regexp capture buffers 27 28 =head1 SYNOPSIS 29 30 tie my %hash, "Tie::Hash::NamedCapture"; 31 # %hash now behaves like %+ 32 33 tie my %hash, "Tie::Hash::NamedCapture", all => 1; 34 # %hash now access buffers from regexp in $qr like %- 35 36 =head1 DESCRIPTION 37 38 This module is used to implement the special hashes C<%+> and C<%->, but it 39 can be used to tie other variables as you choose. 40 41 When the C<all> parameter is provided, then the tied hash elements will be 42 array refs listing the contents of each capture buffer whose name is the 43 same as the associated hash key. If none of these buffers were involved in 44 the match, the contents of that array ref will be as many C<undef> values 45 as there are capture buffers with that name. In other words, the tied hash 46 will behave as C<%->. 47 48 When the C<all> parameter is omitted or false, then the tied hash elements 49 will be the contents of the leftmost defined buffer with the name of the 50 associated hash key. In other words, the tied hash will behave as 51 C<%+>. 52 53 The keys of C<%->-like hashes correspond to all buffer names found in the 54 regular expression; the keys of C<%+>-like hashes list only the names of 55 buffers that have captured (and that are thus associated to defined values). 56 57 =head1 SEE ALSO 58 59 L<perlreapi>, L<re>, L<perlmodlib/Pragmatic Modules>, L<perlvar/"%+">, 60 L<perlvar/"%-">. 61 62 =cut
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |