overloading for union constraints, more tests, some code cleanup
[gitmo/MooseX-Types.git] / lib / MooseX / Types / Util.pm
CommitLineData
52d358e2 1package MooseX::Types::Util;
e211870f 2
3=head1 NAME
4
52d358e2 5MooseX::Types::Util - Common utility functions for the module
e211870f 6
7=cut
8
9use warnings;
10use strict;
11
12use base 'Exporter';
13
14=head1 DESCRIPTION
15
16This package the exportable functions that many parts in
52d358e2 17L<MooseX::Types> might need.
e211870f 18
19=cut
20
21our @EXPORT_OK = qw( filter_tags );
22
23=head1 FUNCTIONS
24
25=head2 filter_tags
26
27Takes a list and returns two references. The first is a hash reference
28containing the tags as keys and the number of their appearance as values.
29The second is an array reference containing all other elements.
30
31=cut
32
33sub 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
52d358e2 48L<MooseX::Types::Moose>, L<Exporter>
e211870f 49
50=head1 AUTHOR AND COPYRIGHT
51
52Robert 'phaylon' Sedlacek C<E<lt>rs@474.atE<gt>>, with many thanks to
53the C<#moose> cabal on C<irc.perl.org>.
54
55=head1 LICENSE
56
57This program is free software; you can redistribute it and/or modify
58it under the same terms as perl itself.
59
60=cut
61
621;