PPI/Token/QuoteLike/Words.pm

filter: Statementstmt 100% 19 / 19 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 96.1% 25 / 26 CC 2 SCAR 3.4
CC
2
Cov
95%
literal
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« PPI/Token/Cast.pm ↑ Summary PPI/Document/Fragment.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 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 63 ▶use PPI::Token::QuoteLike ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 63 ▶use PPI::Token::_QuoteEngine::Full ();
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 63 our $VERSION = '1.260'; # VERSION
33  
34 63 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 ▶ my ( $self ) = @_;
Subroutine literal: called CC=2 SCAR=7.0
Pod documented
51  
52 485 my $content = $self->_section_content(0);
53 485 ▶ return if !defined $content;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $content 0 485 485
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 my ( $left, $right ) = ( $self->_delimiters, '', '' );
59 485 $content =~ s/\\([\Q$left$right\\\E])/$1/g;
60  
61 485 my @words = split ' ', $content;
62  
63 485 return @words;
64 }
65  
66 63 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
« PPI/Token/Cast.pm ↑ Summary PPI/Document/Fragment.pm »