File Coverage

blib/lib/Enumerate/PerlList.pm
Criterion Covered Total %
statement 11 28 39.2
branch n/a
condition n/a
subroutine 4 9 44.4
pod 2 4 50.0
total 17 41 41.4


line stmt bran cond sub pod time code
1             package Enumerate::PerlList;
2              
3 1     1   21060 use 5.006;
  1         4  
4 1     1   6 use strict;
  1         4  
  1         30  
5 1     1   6 use warnings;
  1         12  
  1         29  
6 1     1   5 use Exporter;
  1         1  
  1         394  
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             our $VERSION = '0.01';
19             our $ISA =qw(Exporter);
20             our @EXPORT =qw(enumerate);
21              
22             #-----------------------------------------------------------------------
23             # Call the run method if the module was called as a script
24             #----------------------------------------------------------------------
25             __PACKAGE__->_run unless caller();
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             sub new {
50 0     0 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     0 1   sub index { return $_[0]->[0] }
61              
62             =head2 item
63              
64             =cut
65              
66 0     0 1   sub item {return $_[0]->[1] }
67              
68             =head enumarate
69              
70             =cut
71              
72             sub enumerate {
73 0     0 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             sub _run {
97 0     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<< >>
113              
114             =head1 BUGS
115              
116             Please report any bugs or feature requests to C, or through
117             the web interface at L. 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
137              
138             =item * AnnoCPAN: Annotated CPAN documentation
139              
140             L
141              
142             =item * CPAN Ratings
143              
144             L
145              
146             =item * Search CPAN
147              
148             L
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
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; # End of Enumerate::PerlList