| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id$ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# string::hostname Brik |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
package Metabrik::String::Hostname; |
|
7
|
1
|
|
|
1
|
|
808
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use base qw(Metabrik); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
405
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
|
13
|
|
|
|
|
|
|
return { |
|
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
|
15
|
|
|
|
|
|
|
tags => [ qw(unstable fqdn domain) ], |
|
16
|
|
|
|
|
|
|
author => 'GomoR ', |
|
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
|
18
|
|
|
|
|
|
|
attributes => { |
|
19
|
|
|
|
|
|
|
hostname => [ qw(hostname) ], |
|
20
|
|
|
|
|
|
|
}, |
|
21
|
|
|
|
|
|
|
commands => { |
|
22
|
|
|
|
|
|
|
parse => [ qw(hostname|OPTIONAL) ], |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub parse { |
|
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
29
|
0
|
|
|
|
|
|
my ($hostname) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
0
|
|
|
|
$hostname ||= $self->hostname; |
|
32
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('parse', $hostname) or return; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $tld = ''; |
|
35
|
0
|
|
|
|
|
|
my $domain = ''; |
|
36
|
0
|
|
|
|
|
|
my $host = ''; |
|
37
|
0
|
|
|
|
|
|
my @subdomain_list = (); |
|
38
|
0
|
|
|
|
|
|
my @toks = split('\.', $hostname); |
|
39
|
0
|
0
|
|
|
|
|
if (@toks == 1) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$host = $toks[0]; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
elsif (@toks == 2) { |
|
43
|
0
|
|
|
|
|
|
$tld = $toks[1]; |
|
44
|
0
|
|
|
|
|
|
$domain = $toks[0].'.'.$tld; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
elsif (@toks == 3) { |
|
47
|
0
|
|
|
|
|
|
$tld = $toks[2]; |
|
48
|
0
|
|
|
|
|
|
$domain = $toks[1].'.'.$tld; |
|
49
|
0
|
|
|
|
|
|
$host = $toks[0]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
elsif (@toks > 3) { |
|
52
|
0
|
|
|
|
|
|
$tld = $toks[-1]; |
|
53
|
0
|
|
|
|
|
|
$domain = $toks[-2].'.'.$tld; |
|
54
|
0
|
|
|
|
|
|
$host = $toks[0]; |
|
55
|
0
|
|
|
|
|
|
my $count = @toks - 3; |
|
56
|
0
|
|
|
|
|
|
my $last = $domain; |
|
57
|
0
|
|
|
|
|
|
for my $t (reverse 1..$count) { |
|
58
|
0
|
|
|
|
|
|
$last = $toks[$t].'.'.$last; |
|
59
|
0
|
|
|
|
|
|
push @subdomain_list, $last; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return { |
|
64
|
0
|
|
|
|
|
|
host => $host, |
|
65
|
|
|
|
|
|
|
domain => $domain, |
|
66
|
|
|
|
|
|
|
subdomain_list => \@subdomain_list, |
|
67
|
|
|
|
|
|
|
tld => $tld, |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |