| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sisimai::RFC791; |
|
2
|
100
|
|
|
100
|
|
116983
|
use v5.26; |
|
|
100
|
|
|
|
|
271
|
|
|
3
|
100
|
|
|
100
|
|
348
|
use strict; |
|
|
100
|
|
|
|
|
139
|
|
|
|
100
|
|
|
|
|
1883
|
|
|
4
|
100
|
|
|
100
|
|
306
|
use warnings; |
|
|
100
|
|
|
|
|
163
|
|
|
|
100
|
|
|
|
|
28741
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub is_ipv4address { |
|
7
|
|
|
|
|
|
|
# Returns 1 if the argument is an IPv4 address |
|
8
|
|
|
|
|
|
|
# @param [String] argv1 IPv4 address like "192.0.2.25" |
|
9
|
|
|
|
|
|
|
# @return [Bool] 1: is an IPv4 address |
|
10
|
|
|
|
|
|
|
# @since v5.2.0 |
|
11
|
200140
|
|
|
200140
|
1
|
150838
|
my $class = shift; |
|
12
|
200140
|
100
|
100
|
|
|
214602
|
my $argv0 = shift || return 0; return 0 if length $argv0 < 7; |
|
|
199997
|
|
|
|
|
243674
|
|
|
13
|
75498
|
100
|
|
|
|
83912
|
my @octet = split(/[.]/, $argv0); return 0 if scalar @octet != 4; |
|
|
75498
|
|
|
|
|
121158
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
5683
|
|
|
|
|
6485
|
for my $e ( @octet ) { |
|
16
|
|
|
|
|
|
|
# Check each octet is between 0 and 255 |
|
17
|
16943
|
100
|
|
|
|
39413
|
return 0 unless $e =~ /\A[0-9]{1,3}\z/; my $v = int $e; |
|
|
14826
|
|
|
|
|
15787
|
|
|
18
|
14826
|
100
|
66
|
|
|
32022
|
return 0 if $v < 0 || $v > 255; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
3564
|
|
|
|
|
8592
|
return 1; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub find { |
|
24
|
|
|
|
|
|
|
# Find an IPv4 address from the given string |
|
25
|
|
|
|
|
|
|
# @param [String] argv1 String including an IPv4 address |
|
26
|
|
|
|
|
|
|
# @return [Array] List of IPv4 addresses |
|
27
|
|
|
|
|
|
|
# @since v5.0.0 |
|
28
|
10462
|
|
|
10462
|
1
|
228160
|
my $class = shift; |
|
29
|
10462
|
100
|
100
|
|
|
15106
|
my $argv0 = shift || return undef; return [] if length $argv0 < 7; |
|
|
10461
|
|
|
|
|
13547
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
10460
|
|
|
|
|
14636
|
$argv0 =~ tr/()[],/ /; |
|
32
|
10460
|
|
|
|
|
52177
|
return [grep { $class->is_ipv4address($_) } split(' ', $argv0)]; |
|
|
200057
|
|
|
|
|
189710
|
|
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
|
36
|
|
|
|
|
|
|
__END__ |