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 67     67   525 use strict;
  67         150  
  67         2459  
29 67     67   420 use PPI::Token::QuoteLike ();
  67         152  
  67         1504  
30 67     67   336 use PPI::Token::_QuoteEngine::Full ();
  67         127  
  67         16294  
31              
32             our $VERSION = '1.28401'; # TRIAL
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 487     487 1 1620 my ( $self ) = @_;
51              
52 487         2792 my $content = $self->_section_content(0);
53 487 50       1691 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 487         1929 my ( $left, $right ) = ( $self->_delimiters, '', '' );
59 487         8588 $content =~ s/\\([\Q$left$right\\\E])/$1/g;
60              
61 487         2374 my @words = split ' ', $content;
62              
63 487         4400 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