| 1 | package usw; | ||||||||||||
| 2 | 11 | ▶ | use 5.012005; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 11 | our $VERSION = "0.04"; | |||||||||||
| 5 | |||||||||||||
| 6 | 11 | ▶ | use Encode qw(is_utf8 encode_utf8 decode_utf8); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 11 | ▶ | use utf8(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 11 | ▶ | use strict(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 11 | ▶ | use warnings(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 11 | ▶ | use List::Util qw(first); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | sub import { | ||||||||||||
| 13 | 12 | ▶ | utf8->import; | ||||||||||
|
Subroutine
import: called CC=5 SCAR=16.1
| |||||||||||||
| 14 | 12 | strict->import; | |||||||||||
| 15 | 12 | warnings->import( 'all', FATAL => 'recursion' ); | |||||||||||
| 16 | |||||||||||||
| 17 | 12 | ▶ | my $out = first { $_ =~ /^cp\d+$/ } @_; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 12 | ▶ | $out ||= 'UTF-8'; | ||||||||||
|
Condition50%1/2
$out ||= "UTF-8"
MC/DC0%0/1
$out ||= "UTF-8"
$out
Truth table50%1/2
A
A= $out
| |||||||||||||
| 19 | 11 | ▶ | binmode \*STDIN, ":encoding($out)"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 12 | binmode \*STDOUT, ":encoding($out)"; | |||||||||||
| 21 | 12 | binmode \*STDERR, ":encoding($out)"; | |||||||||||
| 22 | 12 | ▶ | return unless @_; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | |||||||||||||
| 24 | 12 | ▶ | $SIG{__WARN__} = \&_redecode if first { $_ eq 'warn' } @_; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||
| 25 | 3 | ▶ | $SIG{__DIE__} = sub { die _redecode(@_) } | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 26 | 12 | ▶ | if first { $_ eq 'die' } @_; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||
| 27 | |||||||||||||
| 28 | 12 | return; | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | sub _redecode { | ||||||||||||
| 32 | 6 | ▶ | $_[0] =~ /^(.+) at (.+) line (\d+)\.$/; | ||||||||||
|
Subroutine
_redecode: called CC=2 SCAR=6.9
| |||||||||||||
| 33 | 6 | my @texts = split $2, $_[0]; | |||||||||||
| 34 | 6 | ▶ | return is_utf8($1) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | ? $texts[0] . decode_utf8 $2. $texts[1] | ||||||||||||
| 36 | : decode_utf8 $_[0]; | ||||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 11 | 1; | |||||||||||
| 40 | |||||||||||||
| 41 | __END__ | ||||||||||||