File Coverage

blib/lib/P2P/pDonkey/Util.pm
Criterion Covered Total %
statement 17 17 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             # P2P::pDonkey::Util.pm
2             #
3             # Copyright (c) 2003-2004 Alexey klimkin .
4             # All rights reserved.
5             # This program is free software; you can redistribute it and/or
6             # modify it under the same terms as Perl itself.
7             #
8             package P2P::pDonkey::Util;
9              
10 6     6   7417 use 5.006;
  6         66  
  6         240  
11 6     6   34 use strict;
  6         14  
  6         204  
12 6     6   34 use warnings;
  6         10  
  6         855  
13              
14             require Exporter;
15              
16             our $VERSION = '0.05';
17              
18             our @ISA = qw(Exporter);
19              
20             our %EXPORT_TAGS = ( 'all' => [ qw(
21             addr2ip ip2addr
22             ) ] );
23              
24             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25              
26             our @EXPORT = qw(
27            
28             );
29              
30             # Preloaded methods go here.
31              
32 6     6   5967 use Socket qw (inet_aton inet_ntoa);
  6         39004  
  6         2199  
33              
34             sub addr2ip {
35 1     1 1 7 my $ip;
36 1         20 $ip = inet_aton($_[0]);
37 1 50       4 defined $ip || return 0;
38 1         7 return unpack('L', $ip);
39             }
40              
41             sub ip2addr {
42 1     1 1 16 return inet_ntoa(pack('L', $_[0]));
43             }
44              
45             1;
46             __END__