1package Regexp::Common::net::CIDR;
2
3use strict;
4use warnings;
5
6our $VERSION = '0.03';
7
8use Regexp::Common qw(pattern clean no_defaults);
9
10my $ip_unit = "(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])";
11
12pattern name => [qw(net CIDR IPv4)],
13    create => "(?k:$ip_unit\\.$ip_unit(?:\\.$ip_unit)?(?:\\.$ip_unit)?)\\/(?k:3[0-2]|[1-2]?[0-9])";
14
151;
16
17__END__
18
19=head1 NAME
20
21Regexp::Common::net::CIDR -- provide patterns for CIDR blocks.
22
23=head1 SYNOPSIS
24
25    use Regexp::Common ();
26    use Regexp::Common::net::CIDR ();
27
28    while (<>) {
29        /$RE{net}{CIDR}{IPv4}/ and print "Contains a CIDR.\n";
30    }
31
32=head1 DESCRIPTION
33
34Patterns for CIDR blocks. Now only next IPv4 formats are supported:
35
36  xxx.xxx/xx
37  xxx.xxx.xxx/xx
38  xxx.xxx.xxx.xxx/xx
39
40With {-keep} stores address in $1 and number of bits in $2.
41
42=head1 INSTALLATION
43
44  perl Makefile.PL
45  make
46  make install
47
48=head1 CAVEATS
49
50As L<Regexp::Common> doesn't work well with extensions
51named C<Regexp::Common::xxx::yyy> you have to load this extension
52yourself with C<use> or C<require>.
53
54=head1 AUTHOR
55
56Ruslan U. Zakirov <ruz@bestpractical.com>
57
58=cut
59
60