lib/usww.pm

filter: Statementstmt 51.3% 19 / 37 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 6 / 9 Podpod n/a totaltotal 46.3% 25 / 54 CC 5 SCAR 20.4
CC
5
Cov
42%
import
20.0
_redecode
6.0
__ANON__
2.0
CRAP 7.7
« blib/lib/usw.pm ↑ Summary blib/lib/usww.pm »
1 package usww;
2 1 ▶use 5.012005;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 our $VERSION = "0.06";
5  
6 1 ▶use Encode qw(is_utf8 encode_utf8 decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use utf8();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub import {
13 0 ▶ warn "it seems this is NOT Windows" unless $^O eq "MSWin32";
Subroutine import: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
unless $^O eq "MSWin32" 0 0 0
14 0 utf8->import;
15 0 strict->import;
16 0 warnings->import( 'all', FATAL => 'recursion' );
17  
18 0 ▶ my $cp = eval { require Win32; return Win32::GetConsoleCP() }
Branch: 1 branch
BranchTrueFalseTotal
my $cp = eval { do { require Win32; return Win32::GetConsoleCP() } } or die "install 'Win32' module before use it" 0 0 0
19 or die "install 'Win32' module before use it";
20 0 ▶ my $encoding = $@ ? 'UTF-8' : "cp$cp";
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
21 0 $| = 1; # is this irrelevant?
22 #binmode \*STDIN, ":encoding($encoding)";
23 0 binmode \*STDOUT, ":encoding($encoding)";
24 0 binmode \*STDERR, ":encoding($encoding)";
25  
26 0 $SIG{__WARN__} = \&_redecode;
27 0 ▶ $SIG{__DIE__} = sub { die _redecode(@_) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 return;
29 }
30  
31 sub _redecode {
32 0 ▶ $_[0] =~ /^(.+) at (.+) line (\d+)\.$/;
Subroutine _redecode: not called CC=2 SCAR=17.9
33 0 my @texts = split $2, $_[0];
34 0 ▶ return is_utf8($1)
Branch: 1 branch
BranchTrueFalseTotal
&is_utf8($1) ? : 0 0 0
35 ? $texts[0] . decode_utf8 $2. $texts[1]
36 : decode_utf8 $_[0];
37 }
38  
39 1 1;
40  
41 __END__
« blib/lib/usw.pm ↑ Summary blib/lib/usww.pm »