INET6Glue/INET_is_INET6.pm

filter: Statementstmt 100% 35 / 35 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 97.9% 48 / 49 CC 1 SCAR 0.0
CC
1
Cov
98%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« INET6Glue.pm ↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Net::INET6Glue::INET_is_INET6;
4 2 our $VERSION = 0.5;
5  
6 ############################################################################
7 # copy IO::Socket::INET to IO::Socket::INET4
8 # copy IO::Socket::INET6 to IO::Socket::INET
9 ############################################################################
10 2 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use IO::Socket::INET6;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 $INC{'IO/Socket/INET4.pm'} = $INC{'IO/Socket/INET.pm'};
13 2 $INC{'IO/Socket/INET.pm'} = $INC{'IO/Socket/INET6.pm'};
14  
15 {
16 # copy subs
17 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 for ( keys %{IO::Socket::INET::} ) {
20 390 ▶ ref(my $v = $IO::Socket::INET::{$_}) and next;
Branch: 1 branch
BranchTrueFalseTotal
ref(my $v = $IO::Socket::INET::{$_}) and next 0 390 390
21 390 ▶ *{'IO::Socket::INET4::'.$_} = \&{ "IO::Socket::INET::$_" } if *{$v}{CODE};
Branch: 1 branch
BranchTrueFalseTotal
if *{$v;}{"CODE"} 378 12 390
22 }
23  
24 2 for ( keys %{IO::Socket::INET6::} ) {
25 90 ▶ ref(my $v = $IO::Socket::INET6::{$_}) and next;
Branch: 1 branch
BranchTrueFalseTotal
ref(my $v = $IO::Socket::INET6::{$_}) and next 14 76 90
26 76 ▶ *{'IO::Socket::INET::'.$_} = \&{ "IO::Socket::INET6::$_" } if *{$v}{CODE};
Branch: 1 branch
BranchTrueFalseTotal
if *{$v;}{"CODE"} 66 10 76
27 }
28 }
29  
30  
31 2 1;
32  
33 =head1 NAME
34  
35 Net::INET6Glue::INET_is_INET6 - make L<IO::Socket::INET> behave like
36 L<IO::Socket::INET6>
37  
38 =head1 SYNOPSIS
39  
40 use Net::INET6Glue::INET_is_INET6;
41 use LWP::Simple;
42 print get( 'http://[::1]:80' );
43 print get( 'http://ipv6.google.com' );
44  
45 =head1 DESCRIPTION
46  
47 Many modules directly create L<IO::Socket::INET> sockets or have it as a
48 superclass. Because L<IO::Socket::INET> has no support for IPv6 these modules
49 don't have it either.
50  
51 This module tries to make L<IO::Socket::INET> behave like L<IO::Socket::INET6>
52 by copying the symbol table from L<IO::Socket::INET6> into L<IO::Socket::INET>.
53 The original symbol table from L<IO::Socket::INET> is still available in
54 L<IO::Socket::INET4>.
55  
56 This strategy works for L<Net::SMTP>, L<LWP> and probably a lot of other modules
57 too, which don't try to depend too much on the innards of L<IO::Socket::INET> or
58 on the text representation of IP addresses (IPv6 addresses look different than
59 IPv4 addresses).
60  
61 =head1 COPYRIGHT
62  
63 This module is copyright (c) 2008, Steffen Ullrich.
64 All Rights Reserved.
65 This module is free software. It may be used, redistributed and/or modified
66 under the same terms as Perl itself.
« INET6Glue.pm ↑ Summary