File Coverage

blib/lib/Sys/Hostname/FQDN.pm
Criterion Covered Total %
statement 15 17 88.2
branch n/a
condition n/a
subroutine 6 8 75.0
pod 4 4 100.0
total 25 29 86.2


line stmt bran cond sub pod time code
1             package Sys::Hostname::FQDN;
2              
3             #use 5.006;
4 2     2   874 use strict;
  2         2  
  2         70  
5             #use warnings;
6 2     2   9 use Carp;
  2         3  
  2         147  
7              
8 2     2   11 use vars qw($VERSION @ISA @EXPORT_OK);
  2         7  
  2         561  
9              
10             $VERSION = do { my @r = (q$Revision: 0.12 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
11              
12             require Exporter;
13             require DynaLoader;
14             #use AutoLoader;
15              
16             @ISA = qw(Exporter DynaLoader);
17              
18             @EXPORT_OK = qw (
19             asciihostinfo
20             gethostinfo
21             inet_ntoa
22             inet_aton
23             fqdn
24             short
25             );
26              
27             bootstrap Sys::Hostname::FQDN $VERSION;
28              
29             # Preloaded methods go here.
30              
31 0     0   0 sub DESTROY {};
32              
33             # Autoload methods go after =cut, and are processed by the autosplit program.
34              
35             sub short {
36 1     1 1 49 return (split(/\./,&usually_short))[0];
37             }
38              
39             sub fqdn {
40 1     1 1 467 return (gethostbyname(&usually_short))[0];
41             }
42              
43             sub gethostinfo {
44 0     0 1 0 return gethostbyname(&usually_short);
45             }
46              
47             sub asciihostinfo {
48 1     1 1 46 my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname(&usually_short);
49 1         5 for(0..$#addrs) {
50 1         12 $addrs[$_] = inet_ntoa($addrs[$_]);
51             }
52 1         5 return ($name,$aliases,$addrtype,$length,@addrs);
53             }
54              
55             =head1 NAME
56              
57             Sys::Hostname::FQDN - Get the short or long hostname
58              
59             =cut
60              
61             1;
62             __END__