blib/lib/Enumerate/PerlList.pm

filter: Statementstmt 48.4% 16 / 33 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 50.0% 2 / 4 totaltotal 47.9% 23 / 48 CC 4 SCAR 15.8
CC
4
Cov
49%
_run
12.0
enumerate
6.0
new
2.0
CRAP 4.8
↑ Summary
1 package Enumerate::PerlList;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 =head1 NAME
8  
9 Enumerate::PerlList - The great new Enumerate::PerlList!
10 Provide List Enumeration this is code from SPURIN.
11 Original at List::Enumerate
12 =head1 VERSION
13  
14 Version 0.01
15  
16 =cut
17  
18 1 our $VERSION = '0.01';
19 1 our $ISA =qw(Exporter);
20 1 our @EXPORT =qw(enumerate);
21  
22 #-----------------------------------------------------------------------
23 # Call the run method if the module was called as a script
24 #----------------------------------------------------------------------
25 1 ▶__PACKAGE__->_run unless caller();
Branch: 1 branch
BranchTrueFalseTotal
unless caller() 0 1 1
26  
27 =head1 SYNOPSIS
28  
29 Quick summary of what the module does.
30  
31 Perhaps a little code snippet.
32  
33 use Enumerate::PerlList;
34  
35 my $foo = Enumerate::PerlList->new();
36 ...
37  
38 =head1 EXPORT
39  
40 A list of functions that can be exported. You can delete this section
41 if you don't export anything, such as for a purely object-oriented module.
42  
43 =head1 SUBROUTINES/METHODS
44  
45 =head2 Constructor
46  
47 =cut
48  
49 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my $class = shift;
51 0 return bless [@_], $class;
52 }
53  
54 =head2 index
55  
56 The index position
57
58 =cut
59  
60 0 ▶sub index { return $_[0]->[0] }
Subroutine index: not called CC=1 SCAR=6.9
Pod documented
61  
62 =head2 item
63  
64 =cut
65  
66 0 ▶sub item {return $_[0]->[1] }
Subroutine item: not called CC=1 SCAR=6.9
Pod documented
67  
68 =head enumarate
69  
70 =cut
71  
72 0 ▶sub enumerate {
Subroutine enumerate: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my $count =0;
74 0 my @list;
75 0 for my $entry (@_){
76 0 push @list, Enumerate::PerlList->new( $count, $entry);
77 0 $count++;
78 }
79 0 return @list;
80 }
81  
82 =head run
83  
84 Testing subrutine
85 Output
86 0 Cornel
87 1 Andrei
88 2 Florin
89 0 Cornel
90 1 Andrei
91 2 Florin
92
93
94 =cut
95  
96 0 ▶sub _run {
Subroutine _run: not called CC=3 SCAR=24.8
97 0 my @list=qw(Cornel Andrei Florin);
98 # With enumarete
99 0 for my $name (enumerate(@list)){
100 0 print $name->index, " " ,$name->item, "\n";
101 }
102 #Without enumarete
103 0 my $index =0;
104 0 for my $name(@list) {
105 0 print $index," ",$name, "\n";
106 0 $index++;
107 }
108 }
109
110 =head1 AUTHOR
111  
112 Mihai Cornel, C<< <mhcrnl at gmail.com> >>
113  
114 =head1 BUGS
115  
116 Please report any bugs or feature requests to C<bug-enumerate-perllist at rt.cpan.org>, or through
117 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Enumerate-PerlList>. I will be notified, and then you'll
118 automatically be notified of progress on your bug as I make changes.
119  
120  
121  
122  
123 =head1 SUPPORT
124  
125 You can find documentation for this module with the perldoc command.
126  
127 perldoc Enumerate::PerlList
128  
129  
130 You can also look for information at:
131  
132 =over 4
133  
134 =item * RT: CPAN's request tracker (report bugs here)
135  
136 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Enumerate-PerlList>
137  
138 =item * AnnoCPAN: Annotated CPAN documentation
139  
140 L<http://annocpan.org/dist/Enumerate-PerlList>
141  
142 =item * CPAN Ratings
143  
144 L<http://cpanratings.perl.org/d/Enumerate-PerlList>
145  
146 =item * Search CPAN
147  
148 L<http://search.cpan.org/dist/Enumerate-PerlList/>
149  
150 =back
151  
152  
153 =head1 ACKNOWLEDGEMENTS
154  
155  
156 =head1 LICENSE AND COPYRIGHT
157  
158 Copyright 2015 Mihai Cornel.
159  
160 This program is free software; you can redistribute it and/or modify it
161 under the terms of the the Artistic License (2.0). You may obtain a
162 copy of the full license at:
163  
164 L<http://www.perlfoundation.org/artistic_license_2_0>
165  
166 Any use, modification, and distribution of the Standard or Modified
167 Versions is governed by this Artistic License. By using, modifying or
168 distributing the Package, you accept this license. Do not use, modify,
169 or distribute the Package, if you do not accept this license.
170  
171 If your Modified Version has been derived from a Modified Version made
172 by someone other than you, you are nevertheless required to ensure that
173 your Modified Version complies with the requirements of this license.
174  
175 This license does not grant you the right to use any trademark, service
176 mark, tradename, or logo of the Copyright Holder.
177  
178 This license includes the non-exclusive, worldwide, free-of-charge
179 patent license to make, have made, use, offer to sell, sell, import and
180 otherwise transfer the Package with respect to any patent claims
181 licensable by the Copyright Holder that are necessarily infringed by the
182 Package. If you institute patent litigation (including a cross-claim or
183 counterclaim) against any party alleging that the Package constitutes
184 direct or contributory patent infringement, then this Artistic License
185 to you shall terminate on the date that such litigation is filed.
186  
187 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
188 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
189 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
190 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
191 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
192 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
193 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
194 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
195  
196  
197 =cut
198  
199 1 1; # End of Enumerate::PerlList
↑ Summary