| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Quote.pm |
| Statements | Executed 9 statements in 259µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 6.72ms | 47.2ms | PPI::Token::Quote::BEGIN@49 |
| 1 | 1 | 1 | 36µs | 36µs | PPI::Token::Quote::BEGIN@52 |
| 1 | 1 | 1 | 11µs | 22µs | PPI::Token::Quote::BEGIN@48 |
| 1 | 1 | 1 | 10µs | 52µs | PPI::Token::Quote::BEGIN@51 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package PPI::Token::Quote; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | PPI::Token::Quote - String quote abstract base class | ||||
| 8 | |||||
| 9 | =head1 INHERITANCE | ||||
| 10 | |||||
| 11 | PPI::Token::Quote | ||||
| 12 | isa PPI::Token | ||||
| 13 | isa PPI::Element | ||||
| 14 | |||||
| 15 | =head1 DESCRIPTION | ||||
| 16 | |||||
| 17 | The C<PPI::Token::Quote> class is never instantiated, and simply | ||||
| 18 | provides a common abstract base class for the four quote classes. | ||||
| 19 | In PPI, a "quote" is limited to only the quote-like things that | ||||
| 20 | themselves directly represent a string. (although this includes | ||||
| 21 | double quotes with interpolated elements inside them). | ||||
| 22 | |||||
| 23 | The subclasses of C<PPI::Token::Quote> are: | ||||
| 24 | |||||
| 25 | =over 2 | ||||
| 26 | |||||
| 27 | =item C<''> - L<PPI::Token::Quote::Single> | ||||
| 28 | |||||
| 29 | =item C<q{}> - L<PPI::Token::Quote::Literal> | ||||
| 30 | |||||
| 31 | =item C<""> - L<PPI::Token::Quote::Double> | ||||
| 32 | |||||
| 33 | =item C<qq{}> - L<PPI::Token::Quote::Interpolate> | ||||
| 34 | |||||
| 35 | =back | ||||
| 36 | |||||
| 37 | The names are hopefully obvious enough not to have to explain what | ||||
| 38 | each class is here. See their respective pages for more details. | ||||
| 39 | |||||
| 40 | Please note that although the here-doc B<does> represent a literal | ||||
| 41 | string, it is such a nasty piece of work that in L<PPI> it is given the | ||||
| 42 | honor of its own token class (L<PPI::Token::HereDoc>). | ||||
| 43 | |||||
| 44 | =head1 METHODS | ||||
| 45 | |||||
| 46 | =cut | ||||
| 47 | |||||
| 48 | 2 | 17µs | 2 | 32µs | # spent 22µs (11+11) within PPI::Token::Quote::BEGIN@48 which was called:
# once (11µs+11µs) by PPI::Token::Quote::Single::BEGIN@38 at line 48 # spent 22µs making 1 call to PPI::Token::Quote::BEGIN@48
# spent 11µs making 1 call to strict::import |
| 49 | 2 | 98µs | 1 | 47.2ms | # spent 47.2ms (6.72+40.5) within PPI::Token::Quote::BEGIN@49 which was called:
# once (6.72ms+40.5ms) by PPI::Token::Quote::Single::BEGIN@38 at line 49 # spent 47.2ms making 1 call to PPI::Token::Quote::BEGIN@49 |
| 50 | |||||
| 51 | 2 | 46µs | 2 | 93µs | # spent 52µs (10+42) within PPI::Token::Quote::BEGIN@51 which was called:
# once (10µs+42µs) by PPI::Token::Quote::Single::BEGIN@38 at line 51 # spent 52µs making 1 call to PPI::Token::Quote::BEGIN@51
# spent 42µs making 1 call to vars::import |
| 52 | # spent 36µs within PPI::Token::Quote::BEGIN@52 which was called:
# once (36µs+0s) by PPI::Token::Quote::Single::BEGIN@38 at line 55 | ||||
| 53 | 1 | 500ns | $VERSION = '1.215'; | ||
| 54 | 1 | 40µs | @ISA = 'PPI::Token'; | ||
| 55 | 1 | 55µs | 1 | 36µs | } # spent 36µs making 1 call to PPI::Token::Quote::BEGIN@52 |
| 56 | |||||
| - - | |||||
| 61 | ##################################################################### | ||||
| 62 | # PPI::Token::Quote Methods | ||||
| 63 | |||||
| 64 | =pod | ||||
| 65 | |||||
| 66 | =head2 string | ||||
| 67 | |||||
| 68 | The C<string> method is provided by all four ::Quote classes. It won't | ||||
| 69 | get you the actual literal Perl value, but it will strip off the wrapping | ||||
| 70 | of the quotes. | ||||
| 71 | |||||
| 72 | # The following all return foo from the ->string method | ||||
| 73 | 'foo' | ||||
| 74 | "foo" | ||||
| 75 | q{foo} | ||||
| 76 | qq <foo> | ||||
| 77 | |||||
| 78 | =begin testing string 15 | ||||
| 79 | |||||
| 80 | # Prove what we say in the ->string docs | ||||
| 81 | my $Document = PPI::Document->new(\<<'END_PERL'); | ||||
| 82 | 'foo' | ||||
| 83 | "foo" | ||||
| 84 | q{foo} | ||||
| 85 | qq <foo> | ||||
| 86 | END_PERL | ||||
| 87 | isa_ok( $Document, 'PPI::Document' ); | ||||
| 88 | |||||
| 89 | my $quotes = $Document->find('Token::Quote'); | ||||
| 90 | is( ref($quotes), 'ARRAY', 'Found quotes' ); | ||||
| 91 | is( scalar(@$quotes), 4, 'Found 4 quotes' ); | ||||
| 92 | foreach my $Quote ( @$quotes ) { | ||||
| 93 | isa_ok( $Quote, 'PPI::Token::Quote'); | ||||
| 94 | can_ok( $Quote, 'string' ); | ||||
| 95 | is( $Quote->string, 'foo', '->string returns "foo" for ' | ||||
| 96 | . $Quote->content ); | ||||
| 97 | } | ||||
| 98 | |||||
| 99 | =end testing | ||||
| 100 | |||||
| 101 | =cut | ||||
| 102 | |||||
| 103 | #sub string { | ||||
| 104 | # my $class = ref $_[0] || $_[0]; | ||||
| 105 | # die "$class does not implement method ->string"; | ||||
| 106 | #} | ||||
| 107 | |||||
| 108 | =pod | ||||
| 109 | |||||
| 110 | =head2 literal | ||||
| 111 | |||||
| 112 | The C<literal> method is provided by ::Quote:Literal and | ||||
| 113 | ::Quote::Single. This returns the value of the string as Perl sees | ||||
| 114 | it: without the quote marks and with C<\\> and C<\'> resolved to C<\> | ||||
| 115 | and C<'>. | ||||
| 116 | |||||
| 117 | The C<literal> method is not implemented by ::Quote::Double or | ||||
| 118 | ::Quote::Interpolate yet. | ||||
| 119 | |||||
| 120 | =cut | ||||
| 121 | |||||
| 122 | 1 | 2µs | 1; | ||
| 123 | |||||
| 124 | =pod | ||||
| 125 | |||||
| 126 | =head1 SUPPORT | ||||
| 127 | |||||
| 128 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
| 129 | |||||
| 130 | =head1 AUTHOR | ||||
| 131 | |||||
| 132 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
| 133 | |||||
| 134 | =head1 COPYRIGHT | ||||
| 135 | |||||
| 136 | Copyright 2001 - 2011 Adam Kennedy. | ||||
| 137 | |||||
| 138 | This program is free software; you can redistribute | ||||
| 139 | it and/or modify it under the same terms as Perl itself. | ||||
| 140 | |||||
| 141 | The full text of the license can be found in the | ||||
| 142 | LICENSE file included with this module. | ||||
| 143 | |||||
| 144 | =cut |