← Index
NYTProf Performance Profile   « block view • line view • sub view »
For script/nytprof.pl
  Run on Thu May 31 16:29:39 2012
Reported on Thu May 31 16:35:03 2012

Filename/Users/edenc/perl5/lib/perl5/PPI/Token/Quote/Single.pm
StatementsExecuted 12 statements in 425µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111309µs1.29msPPI::Token::Quote::Single::::BEGIN@39PPI::Token::Quote::Single::BEGIN@39
111207µs276µsPPI::Token::Quote::Single::::BEGIN@38PPI::Token::Quote::Single::BEGIN@38
11114µs18µsPPI::Token::Quote::Single::::BEGIN@37PPI::Token::Quote::Single::BEGIN@37
11112µs12µsPPI::Token::Quote::Single::::BEGIN@42PPI::Token::Quote::Single::BEGIN@42
1117µs39µsPPI::Token::Quote::Single::::BEGIN@41PPI::Token::Quote::Single::BEGIN@41
0000s0sPPI::Token::Quote::Single::::literalPPI::Token::Quote::Single::literal
0000s0sPPI::Token::Quote::Single::::stringPPI::Token::Quote::Single::string
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Token::Quote::Single;
2
3=pod
4
5=head1 NAME
6
7PPI::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
24A C<PPI::Token::Quote::Single> object represents a single quoted string
25literal.
26
27=head1 METHODS
28
29There are no methods available for C<PPI::Token::Quote::Single> beyond
30those provided by the parent L<PPI::Token::Quote>, L<PPI::Token> and
31L<PPI::Element> classes.
32
33Got any ideas for methods? Submit a report to rt.cpan.org!
34
35=cut
36
37224µs221µs
# spent 18µs (14+3) within PPI::Token::Quote::Single::BEGIN@37 which was called: # once (14µs+3µs) by PPI::Token::BEGIN@54 at line 37
use strict;
# spent 18µs making 1 call to PPI::Token::Quote::Single::BEGIN@37 # spent 3µs making 1 call to strict::import
382109µs1276µs
# spent 276µs (207+69) within PPI::Token::Quote::Single::BEGIN@38 which was called: # once (207µs+69µs) by PPI::Token::BEGIN@54 at line 38
use PPI::Token::Quote ();
# spent 276µs making 1 call to PPI::Token::Quote::Single::BEGIN@38
39296µs11.29ms
# spent 1.29ms (309µs+980µs) within PPI::Token::Quote::Single::BEGIN@39 which was called: # once (309µs+980µs) by PPI::Token::BEGIN@54 at line 39
use PPI::Token::_QuoteEngine::Simple ();
# spent 1.29ms making 1 call to PPI::Token::Quote::Single::BEGIN@39
40
41238µs271µs
# spent 39µs (7+32) within PPI::Token::Quote::Single::BEGIN@41 which was called: # once (7µs+32µs) by PPI::Token::BEGIN@54 at line 41
use vars qw{$VERSION @ISA};
# spent 39µs making 1 call to PPI::Token::Quote::Single::BEGIN@41 # spent 32µs making 1 call to vars::import
42
# spent 12µs within PPI::Token::Quote::Single::BEGIN@42 which was called: # once (12µs+0s) by PPI::Token::BEGIN@54 at line 48
BEGIN {
43212µs $VERSION = '1.215';
44 @ISA = qw{
45 PPI::Token::_QuoteEngine::Simple
46 PPI::Token::Quote
47 };
481139µs112µs}
# spent 12µ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
61my $Document = PPI::Document->new( \"print 'foo';" );
62isa_ok( $Document, 'PPI::Document' );
63my $Single = $Document->find_first('Token::Quote::Single');
64isa_ok( $Single, 'PPI::Token::Quote::Single' );
65is( $Single->string, 'foo', '->string returns as expected' );
66
67=end testing
68
69=cut
70
71sub string {
72 my $str = $_[0]->{content};
73 substr( $str, 1, length($str) - 2 );
74}
75
76=pod
77
78=begin testing literal 21
79
80my @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);
89while ( @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
10312µsmy %UNESCAPE = (
104 "\\'" => "'",
105 "\\\\" => "\\",
106);
107
108sub literal {
109 # Unescape \\ and \' ONLY
110 my $str = $_[0]->string;
111 $str =~ s/(\\.)/$UNESCAPE{$1} || $1/ge;
112 return $str;
113}
114
11515µs1;
116
117=pod
118
119=head1 SUPPORT
120
121See the L<support section|PPI/SUPPORT> in the main module.
122
123=head1 AUTHOR
124
125Adam Kennedy E<lt>adamk@cpan.orgE<gt>
126
127=head1 COPYRIGHT
128
129Copyright 2001 - 2011 Adam Kennedy.
130
131This program is free software; you can redistribute
132it and/or modify it under the same terms as Perl itself.
133
134The full text of the license can be found in the
135LICENSE file included with this module.
136
137=cut