blib/lib/usw.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 53 CC 5 SCAR 21.6
CC
5
Cov
0%
import
20.0
_redecode
6.0
BEGIN
2.0
CRAP 8.7
1 package usw;
2 use 5.012005;
3  
4 our $VERSION = "0.06";
5  
6 use Encode qw(is_utf8 encode_utf8 decode_utf8);
7 use utf8();
8 use strict();
9 use warnings();
10 use List::Util qw(first);
11  
12 sub import {
13 utf8->import;
14 strict->import;
15 warnings->import( 'all', FATAL => 'recursion' );
16  
17 #binmode \*STDIN, ":encoding(UTF-8)";
18 binmode \*STDOUT, ":encoding(UTF-8)";
19 binmode \*STDERR, ":encoding(UTF-8)";
20 return unless @_;
21  
22 $SIG{__WARN__} = \&_redecode if first { $_ eq 'warn' } @_;
23 $SIG{__DIE__} = sub { die _redecode(@_) }
24 if first { $_ eq 'die' } @_;
25  
26 return;
27 }
28  
29 sub _redecode {
30 $_[0] =~ /^(.+) at (.+) line (\d+)\.$/;
31 my @texts = split $2, $_[0];
32 return is_utf8($1)
33 ? $texts[0] . decode_utf8 $2. $texts[1]
34 : decode_utf8 $_[0];
35 }
36  
37 1;
38  
39 __END__