Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Quote/Single.pm |
Statements | Executed 20 statements in 388µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 218µs | 47.5ms | BEGIN@38 | PPI::Token::Quote::Single::
4 | 1 | 1 | 18µs | 18µs | string | PPI::Token::Quote::Single::
1 | 1 | 1 | 13µs | 13µs | BEGIN@42 | PPI::Token::Quote::Single::
1 | 1 | 1 | 11µs | 22µs | BEGIN@37 | PPI::Token::Quote::Single::
1 | 1 | 1 | 8µs | 52µs | BEGIN@41 | PPI::Token::Quote::Single::
1 | 1 | 1 | 5µs | 5µs | BEGIN@39 | PPI::Token::Quote::Single::
0 | 0 | 0 | 0s | 0s | literal | PPI::Token::Quote::Single::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package PPI::Token::Quote::Single; | ||||
2 | |||||
3 | =pod | ||||
4 | |||||
5 | =head1 NAME | ||||
6 | |||||
7 | PPI::Token::Quote::Single - A 'single quote' token | ||||
8 | |||||
9 | =head1 INHERITANCE | ||||
10 | |||||
11 | PPI::Token::Quote::Single | ||||
12 | isa PPI::Token::Quote | ||||
13 | isa PPI::Token | ||||
14 | isa PPI::Element | ||||
15 | |||||
16 | =head1 SYNOPSIS | ||||
17 | |||||
18 | 'This is a single quote' | ||||
19 | |||||
20 | q{This is a literal, but NOT a single quote} | ||||
21 | |||||
22 | =head1 DESCRIPTION | ||||
23 | |||||
24 | A C<PPI::Token::Quote::Single> object represents a single quoted string | ||||
25 | literal. | ||||
26 | |||||
27 | =head1 METHODS | ||||
28 | |||||
29 | There are no methods available for C<PPI::Token::Quote::Single> beyond | ||||
30 | those provided by the parent L<PPI::Token::Quote>, L<PPI::Token> and | ||||
31 | L<PPI::Element> classes. | ||||
32 | |||||
33 | Got any ideas for methods? Submit a report to rt.cpan.org! | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | 2 | 18µs | 2 | 34µs | # spent 22µs (11+12) within PPI::Token::Quote::Single::BEGIN@37 which was called:
# once (11µs+12µs) by Perl::Critic::Utils::BEGIN@23 at line 37 # spent 22µs making 1 call to PPI::Token::Quote::Single::BEGIN@37
# spent 12µs making 1 call to strict::import |
38 | 2 | 94µs | 1 | 47.5ms | # spent 47.5ms (218µs+47.3) within PPI::Token::Quote::Single::BEGIN@38 which was called:
# once (218µs+47.3ms) by Perl::Critic::Utils::BEGIN@23 at line 38 # spent 47.5ms making 1 call to PPI::Token::Quote::Single::BEGIN@38 |
39 | 2 | 27µs | 1 | 5µs | # spent 5µs within PPI::Token::Quote::Single::BEGIN@39 which was called:
# once (5µs+0s) by Perl::Critic::Utils::BEGIN@23 at line 39 # spent 5µs making 1 call to PPI::Token::Quote::Single::BEGIN@39 |
40 | |||||
41 | 2 | 42µs | 2 | 96µs | # spent 52µs (8+44) within PPI::Token::Quote::Single::BEGIN@41 which was called:
# once (8µs+44µs) by Perl::Critic::Utils::BEGIN@23 at line 41 # spent 52µs making 1 call to PPI::Token::Quote::Single::BEGIN@41
# spent 44µs making 1 call to vars::import |
42 | # spent 13µs within PPI::Token::Quote::Single::BEGIN@42 which was called:
# once (13µs+0s) by Perl::Critic::Utils::BEGIN@23 at line 48 | ||||
43 | 1 | 500ns | $VERSION = '1.215'; | ||
44 | 1 | 13µs | @ISA = qw{ | ||
45 | PPI::Token::_QuoteEngine::Simple | ||||
46 | PPI::Token::Quote | ||||
47 | }; | ||||
48 | 1 | 164µs | 1 | 13µs | } # spent 13µs making 1 call to PPI::Token::Quote::Single::BEGIN@42 |
49 | |||||
- - | |||||
54 | ##################################################################### | ||||
55 | # PPI::Token::Quote Methods | ||||
56 | |||||
57 | =pod | ||||
58 | |||||
59 | =begin testing string 3 | ||||
60 | |||||
61 | my $Document = PPI::Document->new( \"print 'foo';" ); | ||||
62 | isa_ok( $Document, 'PPI::Document' ); | ||||
63 | my $Single = $Document->find_first('Token::Quote::Single'); | ||||
64 | isa_ok( $Single, 'PPI::Token::Quote::Single' ); | ||||
65 | is( $Single->string, 'foo', '->string returns as expected' ); | ||||
66 | |||||
67 | =end testing | ||||
68 | |||||
69 | =cut | ||||
70 | |||||
71 | # spent 18µs within PPI::Token::Quote::Single::string which was called 4 times, avg 4µs/call:
# 4 times (18µs+0s) by Perl::Critic::Policy::InputOutput::RequireEncodingWithUTF8Layer::_get_argument_string at line 68 of Perl/Critic/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm, avg 4µs/call | ||||
72 | 4 | 4µs | my $str = $_[0]->{content}; | ||
73 | 4 | 17µs | substr( $str, 1, length($str) - 2 ); | ||
74 | } | ||||
75 | |||||
76 | =pod | ||||
77 | |||||
78 | =begin testing literal 21 | ||||
79 | |||||
80 | my @pairs = ( | ||||
81 | "''", '', | ||||
82 | "'f'", 'f', | ||||
83 | "'f\\'b'", "f\'b", | ||||
84 | "'f\\nb'", "f\\nb", | ||||
85 | "'f\\\\b'", "f\\b", | ||||
86 | "'f\\\\\\b'", "f\\\\b", | ||||
87 | "'f\\\\\\\''", "f\\'", | ||||
88 | ); | ||||
89 | while ( @pairs ) { | ||||
90 | my $from = shift @pairs; | ||||
91 | my $to = shift @pairs; | ||||
92 | my $doc = PPI::Document->new( \"print $from;" ); | ||||
93 | isa_ok( $doc, 'PPI::Document' ); | ||||
94 | my $quote = $doc->find_first('Token::Quote::Single'); | ||||
95 | isa_ok( $quote, 'PPI::Token::Quote::Single' ); | ||||
96 | is( $quote->literal, $to, "The source $from becomes $to ok" ); | ||||
97 | } | ||||
98 | |||||
99 | =end testing | ||||
100 | |||||
101 | =cut | ||||
102 | |||||
103 | 1 | 3µs | my %UNESCAPE = ( | ||
104 | "\\'" => "'", | ||||
105 | "\\\\" => "\\", | ||||
106 | ); | ||||
107 | |||||
108 | sub literal { | ||||
109 | # Unescape \\ and \' ONLY | ||||
110 | my $str = $_[0]->string; | ||||
111 | $str =~ s/(\\.)/$UNESCAPE{$1} || $1/ge; | ||||
112 | return $str; | ||||
113 | } | ||||
114 | |||||
115 | 1 | 4µs | 1; | ||
116 | |||||
117 | =pod | ||||
118 | |||||
119 | =head1 SUPPORT | ||||
120 | |||||
121 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
122 | |||||
123 | =head1 AUTHOR | ||||
124 | |||||
125 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
126 | |||||
127 | =head1 COPYRIGHT | ||||
128 | |||||
129 | Copyright 2001 - 2011 Adam Kennedy. | ||||
130 | |||||
131 | This program is free software; you can redistribute | ||||
132 | it and/or modify it under the same terms as Perl itself. | ||||
133 | |||||
134 | The full text of the license can be found in the | ||||
135 | LICENSE file included with this module. | ||||
136 | |||||
137 | =cut |