1package List::Flatten;
2
3use warnings;
4use strict;
5
6require Exporter;
7use base qw(Exporter);
8our @EXPORT = qw(flat);
9
10
11=head1 NAME
12
13List::Flatten - Interpolate array references in a list
14
15
16=head1 VERSION
17
18Version 0.01
19
20=cut
21
22our $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
38Exports the only function B<flat> by default.
39
40
41=head1 FUNCTIONS
42
43=head2 flat
44
45B<Arguments:> a list of arbitrary values, parantheses for B<flat> are optional.
46
47B<Returns:> the same list, except that the values of any array references are interpolated into the
48list. Does not work recursively!
49
50=cut
51
52sub flat(@) {
53	return map { ref eq 'ARRAY' ? @$_ : $_ } @_;
54}
55
56
57=head1 AUTHOR
58
59Darko Obradovic, C<< <dobradovic at gmx.de> >>
60
61
62=head1 BUGS
63
64Please report any bugs or feature requests to C<bug-list-flatten at rt.cpan.org>, or through
65the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=List-Flatten>.  I will be notified, and then you'll
66automatically be notified of progress on your bug as I make changes.
67
68
69=head1 SUPPORT
70
71You can find documentation for this module with the perldoc command.
72
73    perldoc List::Flatten
74
75
76You can also look for information at:
77
78=over 4
79
80=item * RT: CPAN's request tracker
81
82L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=List-Flatten>
83
84=item * AnnoCPAN: Annotated CPAN documentation
85
86L<http://annocpan.org/dist/List-Flatten>
87
88=item * CPAN Ratings
89
90L<http://cpanratings.perl.org/d/List-Flatten>
91
92=item * Search CPAN
93
94L<http://search.cpan.org/dist/List-Flatten>
95
96=back
97
98
99=head1 COPYRIGHT & LICENSE
100
101Copyright 2009 Darko Obradovic, all rights reserved.
102
103This program is free software; you can redistribute it and/or modify it
104under the same terms as Perl itself.
105
106=cut
107
1081;
109