| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Structure/Main.pm |
| Statements | Executed 8 statements in 176µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 12µs | 23µs | PPIx::Regexp::Structure::Main::BEGIN@38 |
| 1 | 1 | 1 | 7µs | 11µs | PPIx::Regexp::Structure::Main::BEGIN@39 |
| 1 | 1 | 1 | 7µs | 57µs | PPIx::Regexp::Structure::Main::BEGIN@41 |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Structure::Main::delimiters |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Structure::Main::interpolates |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | =head1 NAME | ||||
| 2 | |||||
| 3 | PPIx::Regexp::Structure::Main - Represent a regular expression proper, or a substitution | ||||
| 4 | |||||
| 5 | =head1 SYNOPSIS | ||||
| 6 | |||||
| 7 | use PPIx::Regexp::Dumper; | ||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{foo}smx' ) | ||||
| 9 | ->print(); | ||||
| 10 | |||||
| 11 | =head1 INHERITANCE | ||||
| 12 | |||||
| 13 | C<PPIx::Regexp::Structure::Main> is a | ||||
| 14 | L<PPIx::Regexp::Structure|PPIx::Regexp::Structure>. | ||||
| 15 | |||||
| 16 | C<PPIx::Regexp::Structure::Main> is the parent of | ||||
| 17 | L<PPIx::Regexp::Structure::Regexp|PPIx::Regexp::Structure::Regexp> and | ||||
| 18 | L<PPIx::Regexp::Structure::Replacement|PPIx::Regexp::Structure::Replacement>. | ||||
| 19 | |||||
| 20 | =head1 DESCRIPTION | ||||
| 21 | |||||
| 22 | This abstract class represents one of the top-level structures in the | ||||
| 23 | expression. Both | ||||
| 24 | L<PPIx::Regexp::Structure::Regexp|PPIx::Regexp::Structure::Regexp> and | ||||
| 25 | L<PPIx::Regexp::Structure::Replacement|PPIx::Regexp::Structure::Replacement> | ||||
| 26 | are derived from it. | ||||
| 27 | |||||
| 28 | =head1 METHODS | ||||
| 29 | |||||
| 30 | This class provides the following public methods. Methods not documented | ||||
| 31 | here are private, and unsupported in the sense that the author reserves | ||||
| 32 | the right to change or remove them without notice. | ||||
| 33 | |||||
| 34 | =cut | ||||
| 35 | |||||
| 36 | package PPIx::Regexp::Structure::Main; | ||||
| 37 | |||||
| 38 | 2 | 18µs | 2 | 34µs | # spent 23µs (12+11) within PPIx::Regexp::Structure::Main::BEGIN@38 which was called:
# once (12µs+11µs) by PPIx::Regexp::Lexer::BEGIN@51 at line 38 # spent 23µs making 1 call to PPIx::Regexp::Structure::Main::BEGIN@38
# spent 11µs making 1 call to strict::import |
| 39 | 2 | 24µs | 2 | 15µs | # spent 11µs (7+4) within PPIx::Regexp::Structure::Main::BEGIN@39 which was called:
# once (7µs+4µs) by PPIx::Regexp::Lexer::BEGIN@51 at line 39 # spent 11µs making 1 call to PPIx::Regexp::Structure::Main::BEGIN@39
# spent 4µs making 1 call to warnings::import |
| 40 | |||||
| 41 | 2 | 131µs | 2 | 108µs | # spent 57µs (7+50) within PPIx::Regexp::Structure::Main::BEGIN@41 which was called:
# once (7µs+50µs) by PPIx::Regexp::Lexer::BEGIN@51 at line 41 # spent 57µs making 1 call to PPIx::Regexp::Structure::Main::BEGIN@41
# spent 50µs making 1 call to base::import |
| 42 | |||||
| 43 | 1 | 500ns | our $VERSION = '0.036'; | ||
| 44 | |||||
| 45 | =head2 delimiters | ||||
| 46 | |||||
| 47 | This method returns a string representing the delimiters of a regular | ||||
| 48 | expression or substitution string. In the case of something like | ||||
| 49 | C<s/foo/bar/>, it will return '//' for both the regular expression and | ||||
| 50 | the replacement. | ||||
| 51 | |||||
| 52 | =cut | ||||
| 53 | |||||
| 54 | sub delimiters { | ||||
| 55 | my ( $self ) = @_; | ||||
| 56 | my @delims; | ||||
| 57 | foreach my $method ( qw{ start finish } ) { | ||||
| 58 | push @delims, undef; | ||||
| 59 | defined ( my $obj = $self->$method() ) | ||||
| 60 | or next; | ||||
| 61 | defined ( my $str = $obj->content() ) | ||||
| 62 | or next; | ||||
| 63 | $delims[-1] = $str; | ||||
| 64 | } | ||||
| 65 | defined ( $delims[0] ) | ||||
| 66 | or $delims[0] = $delims[1]; | ||||
| 67 | return $delims[0] . $delims[1]; | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | =head2 interpolates | ||||
| 71 | |||||
| 72 | This method returns true if the regular expression or replacement | ||||
| 73 | interpolates, and false otherwise. All it really does is to check | ||||
| 74 | whether the ending delimiter is a single quote. | ||||
| 75 | |||||
| 76 | =cut | ||||
| 77 | |||||
| 78 | sub interpolates { | ||||
| 79 | my ( $self ) = @_; | ||||
| 80 | my $finish = $self->finish( 0 ) or return 1; | ||||
| 81 | return q<'> ne $finish->content(); | ||||
| 82 | } | ||||
| 83 | |||||
| 84 | 1 | 2µs | 1; | ||
| 85 | |||||
| 86 | __END__ |