line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Farly::IPv4::Object;
|
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
302
|
use 5.008008;
|
|
19
|
|
|
|
|
70
|
|
|
19
|
|
|
|
|
705
|
|
4
|
19
|
|
|
19
|
|
89
|
use strict;
|
|
19
|
|
|
|
|
33
|
|
|
19
|
|
|
|
|
535
|
|
5
|
19
|
|
|
19
|
|
91
|
use warnings;
|
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
463
|
|
6
|
19
|
|
|
19
|
|
89
|
use Carp;
|
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
11078
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.26';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub size {
|
11
|
45
|
|
|
45
|
1
|
63
|
my ($self) = @_;
|
12
|
45
|
|
|
|
|
104
|
return $self->last - $self->first + 1;
|
13
|
|
|
|
|
|
|
}
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub equals {
|
16
|
220
|
|
|
220
|
1
|
769
|
my ( $self, $other ) = @_;
|
17
|
|
|
|
|
|
|
|
18
|
220
|
100
|
|
|
|
1591
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
19
|
|
|
|
|
|
|
|
20
|
48
|
|
66
|
|
|
142
|
return $self->first == $other->first
|
21
|
|
|
|
|
|
|
&& $self->last == $other->last
|
22
|
|
|
|
|
|
|
&& $self->size == $other->size;
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub contains {
|
27
|
193
|
|
|
193
|
1
|
238
|
my ( $self, $other ) = @_;
|
28
|
|
|
|
|
|
|
|
29
|
193
|
100
|
|
|
|
974
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
30
|
|
|
|
|
|
|
|
31
|
125
|
|
100
|
|
|
335
|
return $self->first <= $other->first
|
32
|
|
|
|
|
|
|
&& $self->last >= $other->last;
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub intersects {
|
37
|
3
|
|
|
3
|
1
|
6
|
my ( $self, $other ) = @_;
|
38
|
|
|
|
|
|
|
|
39
|
3
|
50
|
|
|
|
17
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
40
|
|
|
|
|
|
|
|
41
|
3
|
|
33
|
|
|
9
|
return ( $self->first <= $other->first && $other->first <= $self->last )
|
42
|
|
|
|
|
|
|
|| ( $self->first <= $other->last && $other->last <= $self->last )
|
43
|
|
|
|
|
|
|
|| ( $other->first <= $self->first && $self->first <= $other->last );
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub gt {
|
48
|
59
|
|
|
59
|
1
|
131
|
my ( $self, $other ) = @_;
|
49
|
|
|
|
|
|
|
|
50
|
59
|
50
|
|
|
|
406
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
51
|
|
|
|
|
|
|
|
52
|
59
|
|
|
|
|
158
|
return $self->first > $other->last;
|
53
|
|
|
|
|
|
|
}
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub lt {
|
57
|
5
|
|
|
5
|
1
|
9
|
my ( $self, $other ) = @_;
|
58
|
|
|
|
|
|
|
|
59
|
5
|
50
|
|
|
|
28
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
60
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
16
|
return $self->last < $other->first;
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub adjacent {
|
66
|
7
|
|
|
7
|
1
|
12
|
my ( $self, $other ) = @_;
|
67
|
|
|
|
|
|
|
|
68
|
7
|
50
|
|
|
|
37
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
69
|
|
|
|
|
|
|
|
70
|
7
|
|
100
|
|
|
23
|
return ( ( $self->last + 1 ) == $other->first )
|
71
|
|
|
|
|
|
|
|| ( ( $other->last + 1 ) == $self->first );
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub compare {
|
76
|
115
|
|
|
115
|
0
|
180
|
my ( $self, $other ) = @_;
|
77
|
|
|
|
|
|
|
|
78
|
115
|
50
|
|
|
|
590
|
if ( $other->isa('Farly::IPv4::Object') ) {
|
79
|
|
|
|
|
|
|
|
80
|
115
|
|
100
|
|
|
291
|
return ( $self->first() <=> $other->first()
|
81
|
|
|
|
|
|
|
|| $other->last() <=> $self->last() );
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
}
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1;
|
86
|
|
|
|
|
|
|
__END__
|