DDNS.pm untested

filter: Statementstmt 0.0% 0 / 53 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 75 CC 6 SCAR 22.3
CC
6
Cov
0%
new
20.0
AUTOLOAD
12.0
DESTROY
2.0
CRAP 9.3
1 package Net::DHCP::DDNS;
2 use warnings;
3 use strict;
4  
5 our $VERSION = '0.1';
6  
7 use Carp;
8 use Net::DHCP::DDNS::API;
9 use Net::DHCP::DDNS::Lookup;
10  
11 my %OBJ;
12  
13  
14 sub new {
15 my $class = shift;
16  
17 $class = __PACKAGE__ unless $class;
18 $class = ref($class) if ref($class);
19  
20 unless ( $class->isa( __PACKAGE__ ) ) {
21 croak __PACKAGE__ . "::new($class) asinine!";
22 }
23  
24 my $obj = bless {}, 'Net::DHCP::DDNS::API';
25 my $oid;
26  
27 do {
28 my $t = '';
29  
30 for ( my $i = 0; $i < 10; $i++ ) {
31 $t .= int( rand( 10 ) );
32 }
33  
34 $oid = $t;
35  
36 } until not defined $OBJ{$oid};
37  
38 $OBJ{$oid} = $obj;
39  
40 return bless \( my $this = $oid ), $class;
41 }
42  
43  
44 sub DESTROY {
45 delete $OBJ{${(shift)}};
46 }
47  
48  
49 our $AUTOLOAD;
50  
51 sub AUTOLOAD {
52 my $self = shift;
53  
54 croak "$AUTOLOAD: method not found"
55 unless ref( $self );
56  
57 my $func = $AUTOLOAD;
58 my @func = split /::/, $func;
59 $func = pop @func;
60  
61 croak "$AUTOLOAD: access to private method denied"
62 if $func =~ /^_/;
63  
64 {
65 no strict 'refs';
66 *{$AUTOLOAD} = sub {
67 $OBJ{${(shift)}}->$func( @_ );
68 };
69 }
70  
71 return $OBJ{$$self}->$func( @_ );
72 }
73  
74  
75 1;