5bd5bcf8fb7b58773ecf798c8b3f884e448641f7
[gitmo/MooseX-Types.git] / lib / MooseX / Types / Util.pm
1 package MooseX::Types::Util;
2
3 =head1 NAME
4
5 MooseX::Types::Util - Common utility functions for the module
6
7 =cut
8
9 use warnings;
10 use strict;
11
12 use base 'Exporter';
13
14 =head1 DESCRIPTION
15
16 This package the exportable functions that many parts in 
17 L<MooseX::Types> might need.
18
19 =cut
20
21 our @EXPORT_OK = qw( filter_tags );
22
23 =head1 FUNCTIONS
24
25 =head2 filter_tags
26
27 Takes a list and returns two references. The first is a hash reference
28 containing the tags as keys and the number of their appearance as values.
29 The second is an array reference containing all other elements.
30
31 =cut
32
33 sub filter_tags {
34     my (@list) = @_;
35     my (%tags, @other);
36     for (@list) {
37         if (/^:(.*)$/) {
38             $tags{ $1 }++;
39             next;
40         }
41         push @other, $_;
42     }
43     return \%tags, \@other;
44 }
45
46 =head1 SEE ALSO
47
48 L<MooseX::Types::Moose>, L<Exporter>
49
50 =head1 AUTHOR AND COPYRIGHT
51
52 Robert 'phaylon' Sedlacek C<E<lt>rs@474.atE<gt>>, with many thanks to
53 the C<#moose> cabal on C<irc.perl.org>.
54
55 =head1 LICENSE
56
57 This program is free software; you can redistribute it and/or modify
58 it under the same terms as perl itself.
59
60 =cut
61
62 1;