File Coverage

blib/lib/PPI/Token/QuoteLike/Words.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 22 23 95.6


line stmt bran cond sub pod time code
1             package PPI::Token::QuoteLike::Words;
2              
3             =pod
4              
5             =head1 NAME
6              
7             PPI::Token::QuoteLike::Words - Word list constructor quote-like operator
8              
9             =head1 INHERITANCE
10              
11             PPI::Token::QuoteLike::Words
12             isa PPI::Token::QuoteLike
13             isa PPI::Token
14             isa PPI::Element
15              
16             =head1 DESCRIPTION
17              
18             A C<PPI::Token::QuoteLike::Words> object represents a quote-like operator
19             that acts as a constructor for a list of words.
20              
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};
23              
24             =head1 METHODS
25              
26             =cut
27              
28 67     67   363 use strict;
  67         99  
  67         1850  
29 67     67   256 use PPI::Token::QuoteLike ();
  67         102  
  67         936  
30 67     67   296 use PPI::Token::_QuoteEngine::Full ();
  67         110  
  67         12123  
31              
32             our $VERSION = '1.284';
33              
34             our @ISA = qw{
35             PPI::Token::_QuoteEngine::Full
36             PPI::Token::QuoteLike
37             };
38              
39             =pod
40              
41             =head2 literal
42              
43             Returns the words contained as a list. Note that this method does not check the
44             context that the token is in; it always returns the list and not merely
45             the last element if the token is in scalar context.
46              
47             =cut
48              
49             sub literal {
50 512     512 1 931 my ( $self ) = @_;
51              
52 512         1541 my $content = $self->_section_content(0);
53 512 50       1263 return if !defined $content;
54              
55             # Undo backslash escaping of '\', the left delimiter,
56             # and the right delimiter. The right delimiter will
57             # only exist with paired delimiters: qw() qw[] qw<> qw{}.
58 512         1054 my ( $left, $right ) = ( $self->_delimiters, '', '' );
59 512         4748 $content =~ s/\\([\Q$left$right\\\E])/$1/g;
60              
61 512         1240 my @words = split ' ', $content;
62              
63 512         2055 return @words;
64             }
65              
66             1;
67              
68             =pod
69              
70             =head1 SUPPORT
71              
72             See the L<support section|PPI/SUPPORT> in the main module.
73              
74             =head1 AUTHOR
75              
76             Adam Kennedy E<lt>adamk@cpan.orgE<gt>
77              
78             =head1 COPYRIGHT
79              
80             Copyright 2001 - 2011 Adam Kennedy.
81              
82             This program is free software; you can redistribute
83             it and/or modify it under the same terms as Perl itself.
84              
85             The full text of the license can be found in the
86             LICENSE file included with this module.
87              
88             =cut