| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | PPIx::Regexp::Structure::NamedCapture - Represent a named capture | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | use PPIx::Regexp::Dumper; | ||||||||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{(?<foo>foo)}smx' ) | ||||||||||
| 9 | ->print(); | ||||||||||
| 10 | |||||||||||
| 11 | =head1 INHERITANCE | ||||||||||
| 12 | |||||||||||
| 13 | C<PPIx::Regexp::Structure::NamedCapture> is a | ||||||||||
| 14 | L<PPIx::Regexp::Structure::Capture|PPIx::Regexp::Structure::Capture>. | ||||||||||
| 15 | |||||||||||
| 16 | C<PPIx::Regexp::Structure::NamedCapture> has no descendants. | ||||||||||
| 17 | |||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||
| 19 | |||||||||||
| 20 | This class represents a named capture. Its content will be something | ||||||||||
| 21 | like one of the following: | ||||||||||
| 22 | |||||||||||
| 23 | (?<NAME> ... ) | ||||||||||
| 24 | (?'NAME' ... ) | ||||||||||
| 25 | (?P<NAME> ... ) | ||||||||||
| 26 | |||||||||||
| 27 | =head1 METHODS | ||||||||||
| 28 | |||||||||||
| 29 | This class provides the following public methods. Methods not documented | ||||||||||
| 30 | here are private, and unsupported in the sense that the author reserves | ||||||||||
| 31 | the right to change or remove them without notice. | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | package PPIx::Regexp::Structure::NamedCapture; | ||||||||||
| 36 | |||||||||||
| 37 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 9 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 9 | ▶ | use base qw{ PPIx::Regexp::Structure::Capture }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | 9 | ▶ | use PPIx::Regexp::Constant qw{ @CARP_NOT }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | |||||||||||
| 46 | 9 | our $VERSION = '0.092'; | |||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | sub explain { | ||||||||
|
Subroutine
explain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 49 | 1 | my ( $self ) = @_; | |||||||||
| 50 | 1 | return sprintf q<Named capture group '%s' (number %d)>, | |||||||||
| 51 | $self->name(), $self->number(); | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | =head2 name | ||||||||||
| 55 | |||||||||||
| 56 | my $name = $element->name(); | ||||||||||
| 57 | |||||||||||
| 58 | This method returns the name of the capture. | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | 29 | ▶ | sub name { | ||||||||
|
Subroutine
name: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 63 | 29 | my ( $self ) = @_; | |||||||||
| 64 | 29 | ▶ | my $type = $self->type() | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | or croak 'Programming error - ', __PACKAGE__, ' without type object'; | ||||||||||
| 66 | 29 | return $type->name(); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 9 | 1; | |||||||||
| 70 | |||||||||||
| 71 | __END__ | ||||||||||