1 package PPI::Token::QuoteLike::Words;
7 PPI::Token::QuoteLike::Words - Word list constructor quote-like operator
11 PPI::Token::QuoteLike::Words
12 isa PPI::Token::QuoteLike
18 A C<PPI::Token::QuoteLike::Words> object represents a quote-like operator
19 that acts as a constructor for a list of words.
21 # Create a list for a significant chunk of the alphabet
22 my @list = qw{a b c d e f g h i j k l};
29 use PPI::Token::QuoteLike ();
30 use PPI::Token::_QuoteEngine::Full ();
32 use vars qw{$VERSION @ISA};
36 PPI::Token::_QuoteEngine::Full
45 Returns the words contained. Note that this method does not check the
46 context that the token is in; it always returns the list and not merely
47 the last element if the token is in scalar context.
49 =begin testing literal 16
51 my $empty_list_document = PPI::Document->new(\<<'END_PERL');
56 isa_ok( $empty_list_document, 'PPI::Document' );
57 my $empty_list_tokens =
58 $empty_list_document->find('PPI::Token::QuoteLike::Words');
59 is( scalar @{$empty_list_tokens}, 2, 'Found expected empty word lists.' );
60 foreach my $token ( @{$empty_list_tokens} ) {
61 my @literal = $token->literal;
62 is( scalar @literal, 0, qq<No elements for "$token"> );
65 my $non_empty_list_document = PPI::Document->new(\<<'END_PERL');
69 my @expected = qw/ foo bar baz /;
71 isa_ok( $non_empty_list_document, 'PPI::Document' );
72 my $non_empty_list_tokens =
73 $non_empty_list_document->find('PPI::Token::QuoteLike::Words');
75 scalar @{$non_empty_list_tokens},
77 'Found expected non-empty word lists.',
79 foreach my $token ( @{$non_empty_list_tokens} ) {
80 my $literal = $token->literal;
84 qq<Scalar context literal() returns the list for "$token">,
86 my @literal = $token->literal;
87 is( scalar @literal, scalar @expected, qq<Element count for "$token"> );
88 for (my $x = 0; $x < @expected; $x++) {
89 is( $literal[$x], $expected[$x], qq<Element $x of "$token"> );
99 my $content = $self->content;
100 $content = substr( $self->content, 3, length($content) - 4 );
101 return split ' ', $content;
110 See the L<support section|PPI/SUPPORT> in the main module.
114 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
118 Copyright 2001 - 2009 Adam Kennedy.
120 This program is free software; you can redistribute
121 it and/or modify it under the same terms as Perl itself.
123 The full text of the license can be found in the
124 LICENSE file included with this module.