1 package PPI::Token::Quote::Single;
7 PPI::Token::Quote::Single - A 'single quote' token
11 PPI::Token::Quote::Single
18 'This is a single quote'
20 q{This is a literal, but NOT a single quote}
24 A C<PPI::Token::Quote::Single> object represents a single quoted string
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.
33 Got any ideas for methods? Submit a report to rt.cpan.org!
38 use PPI::Token::Quote ();
39 use PPI::Token::_QuoteEngine::Simple ();
41 use vars qw{$VERSION @ISA};
45 PPI::Token::_QuoteEngine::Simple
54 #####################################################################
55 # PPI::Token::Quote Methods
59 =begin testing string 3
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' );
72 my $str = $_[0]->{content};
73 substr( $str, 1, length($str) - 2 );
78 =begin testing literal 21
86 "'f\\\\\\b'", "f\\\\b",
87 "'f\\\\\\\''", "f\\'",
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" );
109 # Unescape \\ and \' ONLY
110 my $str = $_[0]->string;
111 $str =~ s/(\\.)/$UNESCAPE{$1} || $1/ge;
121 See the L<support section|PPI/SUPPORT> in the main module.
125 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
129 Copyright 2001 - 2009 Adam Kennedy.
131 This program is free software; you can redistribute
132 it and/or modify it under the same terms as Perl itself.
134 The full text of the license can be found in the
135 LICENSE file included with this module.