PPI/Token/QuoteLike/Words.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 96.7% 30 / 31 CC 2 SCAR 2.5
CC
2
Cov
96%
literal
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« PPI/Token/ArrayIndex.pm ↑ Summary PPI/Token/Quote/Single.pm »
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 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 62 ▶use PPI::Token::QuoteLike ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 62 ▶use PPI::Token::_QuoteEngine::Full ();
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 62 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
33 BEGIN {
34 62 ▶ $VERSION = '1.236';
Subroutine BEGIN: called CC=1 SCAR=0.0
35 62 @ISA = qw{
36 PPI::Token::_QuoteEngine::Full
37 PPI::Token::QuoteLike
38 };
39 }
40  
41 =pod
42  
43 =head2 literal
44  
45 Returns the words contained as a list. 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.
48  
49 =cut
50  
51 sub literal {
52 485 ▶ my ( $self ) = @_;
Subroutine literal: called CC=2 SCAR=7.0
Pod documented
53  
54 485 my $content = $self->_section_content(0);
55 485 ▶ return if !defined $content;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $content 0 485 485
56  
57 # Undo backslash escaping of '\', the left delimiter,
58 # and the right delimiter. The right delimiter will
59 # only exist with paired delimiters: qw() qw[] qw<> qw{}.
60 485 my ( $left, $right ) = ( $self->_delimiters, '', '' );
61 485 $content =~ s/\\([\Q$left$right\\\E])/$1/g;
62  
63 485 my @words = split ' ', $content;
64  
65 485 return @words;
66 }
67  
68 62 1;
69  
70 =pod
71  
72 =head1 SUPPORT
73  
74 See the L<support section|PPI/SUPPORT> in the main module.
75  
76 =head1 AUTHOR
77  
78 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
79  
80 =head1 COPYRIGHT
81  
82 Copyright 2001 - 2011 Adam Kennedy.
83  
84 This program is free software; you can redistribute
85 it and/or modify it under the same terms as Perl itself.
86  
87 The full text of the license can be found in the
88 LICENSE file included with this module.
89  
90 =cut
« PPI/Token/ArrayIndex.pm ↑ Summary PPI/Token/Quote/Single.pm »