File Coverage

blib/lib/List/Flatten.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 18 18 100.0


line stmt bran cond sub pod time code
1             package List::Flatten;
2              
3 2     2   75070 use warnings;
  2         7  
  2         134  
4 2     2   13 use strict;
  2         4  
  2         92  
5              
6             require Exporter;
7 2     2   12 use base qw(Exporter);
  2         9  
  2         438  
8             our @EXPORT = qw(flat);
9              
10              
11             =head1 NAME
12              
13             List::Flatten - Interpolate array references in a list
14              
15              
16             =head1 VERSION
17              
18             Version 0.01
19              
20             =cut
21              
22             our $VERSION = '0.01';
23              
24              
25             =head1 SYNOPSIS
26              
27             use List::Flatten;
28              
29             my @foo = (1, 2, [3, 4, 5], 6, [7, 8], 9);
30             # @foo contains 6 elements, 2 of them are array references
31            
32             my @bar = flat @foo;
33             # @bar contains 9 elements, same as (1 .. 9)
34              
35              
36             =head1 EXPORT
37              
38             Exports the only function B by default.
39              
40              
41             =head1 FUNCTIONS
42              
43             =head2 flat
44              
45             B a list of arbitrary values, parantheses for B are optional.
46              
47             B the same list, except that the values of any array references are interpolated into the
48             list. Does not work recursively!
49              
50             =cut
51              
52             sub flat(@) {
53 2 100   2 1 1228 return map { ref eq 'ARRAY' ? @$_ : $_ } @_;
  10         47  
54             }
55              
56              
57             =head1 AUTHOR
58              
59             Darko Obradovic, C<< >>
60              
61              
62             =head1 BUGS
63              
64             Please report any bugs or feature requests to C, or through
65             the web interface at L. I will be notified, and then you'll
66             automatically be notified of progress on your bug as I make changes.
67              
68              
69             =head1 SUPPORT
70              
71             You can find documentation for this module with the perldoc command.
72              
73             perldoc List::Flatten
74              
75              
76             You can also look for information at:
77              
78             =over 4
79              
80             =item * RT: CPAN's request tracker
81              
82             L
83              
84             =item * AnnoCPAN: Annotated CPAN documentation
85              
86             L
87              
88             =item * CPAN Ratings
89              
90             L
91              
92             =item * Search CPAN
93              
94             L
95              
96             =back
97              
98              
99             =head1 COPYRIGHT & LICENSE
100              
101             Copyright 2009 Darko Obradovic, all rights reserved.
102              
103             This program is free software; you can redistribute it and/or modify it
104             under the same terms as Perl itself.
105              
106             =cut
107              
108             1;