/usr/share/perl5/MooseX/Types/NetAddr/IP.pm is in libmoosex-types-netaddr-ip-perl 0.06-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | package MooseX::Types::NetAddr::IP;
use strict;
use warnings;
our $VERSION = '0.06';
use Class::Load 0.20 qw( load_class );
use MooseX::Types::Moose qw/Str ArrayRef/;
use namespace::clean;
use MooseX::Types -declare => [qw( NetAddrIP NetAddrIPv4 NetAddrIPv6 )];
class_type 'NetAddr::IP';
subtype NetAddrIP, as 'NetAddr::IP'; # can be either IPv4 or IPv6
subtype NetAddrIPv4, as 'NetAddr::IP'; # can be only IPv4
subtype NetAddrIPv6, as 'NetAddr::IP'; # can be only IPv6
coerce NetAddrIP,
from Str,
via {
return load_class('NetAddr::IP')->new( $_ )
or die "'$_' is not an IP address.\n";
};
coerce NetAddrIP,
from ArrayRef[Str],
via {
return load_class('NetAddr::IP')->new( @$_ )
or die "'@$_' is not an IP address.\n";
};
sub createAddress ($@) {
my $version = shift;
my $ipaddr = load_class('NetAddr::IP')->new( @_ )
or die "'@_' is not an IPv$version address.\n";
die "'@_' is not an IPv$version address."
unless $ipaddr->version == $version;
return $ipaddr;
}
coerce NetAddrIPv4,
from Str,
via { createAddress 4 => $_ };
coerce NetAddrIPv4,
from ArrayRef[Str],
via { createAddress 4 => @$_ };
coerce NetAddrIPv6,
from Str,
via { createAddress 6 => $_ };
coerce NetAddrIPv6,
from ArrayRef[Str],
via { createAddress 6 => @$_ };
1;
__END__
=head1 NAME
MooseX::Types::NetAddr::IP - NetAddr::IP related types and coercions for Moose
=head1 SYNOPSIS
use MooseX::Types::NetAddr::IP qw( NetAddrIP NetAddrIPv4 NetAddrIPv6 );
=head1 DESCRIPTION
This package provides internet address types for Moose.
=head2 TYPES
NetAddrIP
Coerces from Str and ArrayRef via "new" in NetAddr::IP.
NetAddrIPv4
Coerces from Str and ArrayRef via "new" in NetAddr::IP.
NetAddrIPv6
Coerces from Str and ArrayRef via "new" in NetAddr::IP.
=head1 SEE ALSO
L<NetAddr::IP>, L<MooseX::Types>
=head1 AUTHOR
Todd Caine, E<lt>todd.caine@gmail.comE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2010 by Todd Caine
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.1 or,
at your option, any later version of Perl 5 you may have available.
=cut
|