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 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 65     65   377 use strict;
  65         113  
  65         1467  
29 65     65   275 use PPI::Token::QuoteLike ();
  65         112  
  65         706  
30 65     65   240 use PPI::Token::_QuoteEngine::Full ();
  65         119  
  65         9980  
31              
32             our $VERSION = '1.276';
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 485     485 1 935 my ( $self ) = @_;
51              
52 485         1288 my $content = $self->_section_content(0);
53 485 50       933 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 485         955 my ( $left, $right ) = ( $self->_delimiters, '', '' );
59 485         3194 $content =~ s/\\([\Q$left$right\\\E])/$1/g;
60              
61 485         1215 my @words = split ' ', $content;
62              
63 485         2243 return @words;
64             }
65              
66             1;
67              
68             =pod
69              
70             =head1 SUPPORT
71              
72             See the L in the main module.
73              
74             =head1 AUTHOR
75              
76             Adam Kennedy Eadamk@cpan.orgE
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