| 1 | package Class::Usul::Functions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 27 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 27 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 27 | ▶ | use parent 'Exporter::Tiny'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 27 | ▶ | use Class::Inspector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 27 | ▶ | use Class::Null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 27 | ▶ | use Class::Usul::Constants qw( ASSERT DEFAULT_CONFHOME DEFAULT_ENVDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | DIGEST_ALGORITHMS EXCEPTION_CLASS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | PERL_EXTNS PREFIX UNTAINT_CMDLINE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 27 | UNTAINT_IDENTIFIER UNTAINT_PATH UUID_PATH ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 27 | ▶ | use Cwd qw( ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 27 | ▶ | use Data::Printer alias => q(_data_dumper), colored => 1, indent => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | filters => { 'DateTime' => sub { $_[ 0 ].q() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | 'File::DataClass::IO' => sub { $_[ 0 ]->pathname }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | 'JSON::XS::Boolean' => sub { $_[ 0 ].q() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | 'Type::Tiny' => sub { $_[ 0 ]->display_name }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | 'Type::Tiny::Enum' => sub { $_[ 0 ]->display_name }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | 'Type::Tiny::Union' => sub { $_[ 0 ]->display_name }, }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 27 | ▶ | use Digest qw( ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 27 | ▶ | use Digest::MD5 qw( md5 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 27 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 27 | ▶ | use Fcntl qw( F_SETFL O_NONBLOCK ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 27 | ▶ | use File::Basename qw( basename dirname ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 27 | ▶ | use File::DataClass::Functions qw( supported_extensions ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 27 | ▶ | use File::DataClass::IO qw( ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 27 | ▶ | use File::HomeDir qw( ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 27 | ▶ | use File::Spec::Functions qw( canonpath catdir catfile curdir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 27 | ▶ | use List::Util qw( first ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 27 | ▶ | use Module::Runtime qw( is_module_name require_module ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 27 | ▶ | use Scalar::Util qw( blessed openhandle ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 27 | ▶ | use Socket qw( AF_UNIX SOCK_STREAM PF_UNSPEC ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 27 | ▶ | use Symbol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 27 | ▶ | use Sys::Hostname qw( hostname ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 27 | ▶ | use Unexpected::Functions qw( is_class_loaded PathAlreadyExists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 27 | PathNotFound Tainted Unspecified ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 27 | ▶ | use User::pwent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 27 | our @EXPORT_OK = qw( abs_path app_prefix arg_list assert assert_directory | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | base64_decode_ns base64_encode_ns bsonid bsonid_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | bson64id bson64id_time canonicalise class2appdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | classdir classfile create_token create_token64 cwdp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | dash2under data_dumper digest distname elapsed emit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | emit_err emit_to ensure_class_loaded env_prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | escape_TT exception find_apphome find_source first_char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | fqdn fullname get_cfgfiles get_user hex2str home2appldir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | io is_arrayref is_coderef is_hashref is_member is_win32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | list_attr_of loginid logname merge_attributes my_prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | nonblocking_write_pipe_pair ns_environment pad | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | prefix2class socket_pair split_on__ split_on_dash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | squeeze strip_leader sub_name symlink thread_id throw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | throw_on_error trim unescape_TT untaint_cmdline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | untaint_identifier untaint_path untaint_string urandom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | uuid whiten zip chain compose curry fold Y factorial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | fibonacci product sum ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | our %EXPORT_REFS = ( assert => sub { ASSERT }, ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 27 | our %EXPORT_TAGS = ( all => [ @EXPORT_OK ], ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Package variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 27 | my $bson_id_count : shared = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 27 | my $bson2_id_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 27 | my $bson2_prev_time = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 27 | my $digest_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 27 | my $host_id = substr md5( hostname ), 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # Private functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | my $_base64_char_set = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | return [ 0 .. 9, 'A' .. 'Z', '_', 'a' .. 'z', '~', '+' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | my $_bsonid_inc = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | my ($now, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | $version or return substr pack( 'N', $bson_id_count++ % 0xFFFFFF ), 1, 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | $bson2_id_count++; $now > $bson2_prev_time and $bson2_id_count = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | $bson2_prev_time = $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | $version < 2 and return (substr pack( 'n', thread_id() % 0xFF ), 1, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | .(pack 'n', $bson2_id_count % 0xFFFF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | $version < 3 and return (pack 'n', thread_id() % 0xFFFF ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | .(pack 'n', $bson2_id_count % 0xFFFF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return (pack 'n', thread_id() % 0xFFFF ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | .(substr pack( 'N', $bson2_id_count % 0xFFFFFF ), 1, 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | my $_bsonid_time = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my ($now, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | (not $version or $version < 2) and return pack 'N', $now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $version or $version < 2
MC/DC50%1/2
not $version or $version < 2
not $version
$version < 2
Truth table66%2/3
not(A) or B
A= not $versionB= $version < 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | $version < 3 and return (substr pack( 'N', $now >> 32 ), 2, 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | .(pack 'N', $now % 0xFFFFFFFF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return (pack 'N', $now >> 32).(pack 'N', $now % 0xFFFFFFFF); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 307 | ▶ | my $_catpath = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 307 | return untaint_path( catfile( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 21 | ▶ | my $_get_env_var_for_conf = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 21 | ▶ | my $file = $ENV{ ($_[ 0 ] || return) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] || (return)
MC/DC0%0/1
$_[0] || (return)
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 21 | ▶ | my $path = $file ? dirname( $file ) : q(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 21 | ▶ | return $path = assert_directory( $path ) ? $path : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 45 | ▶ | my $_get_pod_content_for_attr = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 45 | my ($class, $attr) = @_; my $pod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 45 | ▶ | my $src = find_source( $class ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | or throw( 'Class [_1] cannot find source', [ $class ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 45 | my $events = Pod::Eventual::Simple->read_file( $src ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 45 | ▶ | for (my $ev_no = 0, my $max = @{ $events }; $ev_no < $max; $ev_no++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4158 | ▶ | my $ev = $events->[ $ev_no ]; $ev->{type} eq 'command' or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1025 | ▶ | $ev->{content} =~ m{ (?: ^|[< ]) $attr (?: [ >]|$ ) }msx or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 45 | ▶ | $ev_no++ while ($ev = $events->[ $ev_no + 1 ] and $ev->{type} eq 'blank'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ev = $$events[$ev_no + 1] and $ev->{"type"} eq "blank"
MC/DC50%1/2
$ev = $$events[$ev_no + 1] and $ev->{"type"} eq "blank"
$ev = $$events[$ev_no + 1]
$ev->{"type"} eq "blank"
Truth table66%2/3
A and B
A= $ev = $$events[$ev_no + 1]B= $ev->{"type"} eq "blank"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 45 | ▶ | $ev and $ev->{type} eq 'text' and $pod = $ev->{content} and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ev and $ev->{"type"} eq "text" and $pod = $ev->{"content"}
$ev and $ev->{"type"} eq "text"
MC/DC0%0/3
$ev and $ev->{"type"} eq "text" and $pod = $ev->{"content"}
$ev
$ev->{"type"} eq "text"
$pod = $ev->{"content"}
Truth table25%1/4
A and B and C
A= $evB= $ev->{"type"} eq "text"C= $pod = $ev->{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 45 | ▶ | $pod //= 'Undocumented'; chomp $pod; $pod =~ s{ [\n] }{ }gmx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$pod //= "Undocumented"
MC/DC0%0/1
$pod //= "Undocumented"
$pod
Truth table50%1/2
A
A= $pod
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 45 | ▶ | $pod = squeeze( $pod ); $pod =~ m{ \A (.+) \z }msx and $pod = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 45 | return $pod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | my $_index64 = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | return [ qw(XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | XX XX XX XX XX XX XX XX XX XX XX 64 XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 1 2 3 4 5 6 7 8 9 XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | XX 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 25 26 27 28 29 30 31 32 33 34 35 XX XX XX XX 36 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | XX 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 52 53 54 55 56 57 58 59 60 61 62 XX XX XX 63 XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my $_pseudo_random = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return join q(), time, rand 10_000, $PID, {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | my $_bsonid = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my $version = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | my $time = $_bsonid_time->( $now, $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | my $pid = pack 'n', $PID % 0xFFFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | return $time.$host_id.$pid.$_bsonid_inc->( $now, $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 42 | ▶ | my $_find_cfg_in_inc = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 42 | my ($classdir, $file, $extns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 42 | ▶ | for my $dir (grep { defined and -d $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && -d $_
MC/DC100%2/2
defined $_ && -d $_
defined $_
-d $_
Truth table100%3/3
A && B
A= defined $_B= -d $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 588 | map { abs_path( catdir( $_, $classdir ) ) } @INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 120 | ▶ | for my $extn (@{ $extns // [ supported_extensions() ] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$extns // [&supported_extensions()]
MC/DC0%0/1
$extns // [&supported_extensions()]
$extns
Truth table50%1/2
A
A= $extns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 144 | my $path = $_catpath->( $dir, $file.$extn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 144 | ▶ | -f $path and return dirname( $path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 42 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 63 | ▶ | my $_read_variable = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=24.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 63 | my ($dir, $file, $variable) = @_; my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 63 | ▶ | ($dir and $file and $variable) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$dir and $file and $variable
$dir and $file
MC/DC0%0/3
$dir and $file and $variable
$dir
$file
$variable
Truth table25%1/4
A and B and C
A= $dirB= $fileC= $variable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 63 | ▶ | is_arrayref( $dir ) and $dir = catdir( @{ $dir } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 63 | $path = io( $_catpath->( $dir, $file ) )->chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 63 | ▶ | ($path->exists and $path->is_file) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$path->exists and $path->is_file
MC/DC0%0/2
$path->exists and $path->is_file
$path->exists
$path->is_file
Truth table33%1/3
A and B
A= $path->existsB= $path->is_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | return first { length } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | map { trim( (split '=', $_)[ 1 ] ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | grep { m{ \A \s* $variable \s* [=] }mx } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | reverse $path->getlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 42 | ▶ | my $_get_file_var = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 42 | my ($dir, $file, $classdir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 42 | ▶ | my $path; $path = $_read_variable->( $dir, ".${file}", 'APPLDIR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | and $path = catdir( $path, 'lib', $classdir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 42 | ▶ | return $path = assert_directory( $path ) ? $path : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 21 | ▶ | my $_get_known_file_var = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 21 | ▶ | my ($appname, $classdir) = @_; length $appname or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 21 | ▶ | my $path; $path = $_read_variable->( DEFAULT_ENVDIR(), $appname, 'APPLDIR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | and $path = catdir( $path, 'lib', $classdir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 21 | ▶ | return $path = assert_directory( $path ) ? $path : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Construction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | sub _exporter_fail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_fail: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | my ($class, $name, $value, $globals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | exists $EXPORT_REFS{ $name } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | and return ( $name => $EXPORT_REFS{ $name }->() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | throw( 'Subroutine [_1] not found in package [_2]', [ $name, $class ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # Public functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 968 | ▶ | sub abs_path ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abs_path: called CC=7 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 968 | ▶ | my $v = shift; (defined $v and length $v) or return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $v and length $v
MC/DC100%2/2
defined $v and length $v
defined $v
length $v
Truth table100%3/3
A and B
A= defined $vB= length $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 842 | ▶ | is_ntfs() and not -e $v and return untaint_path( $v ); # Hate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&is_ntfs() and not -e $v
MC/DC0%0/2
&is_ntfs() and not -e $v
&is_ntfs()
not -e $v
Truth table33%1/3
A and not(B)
A= &is_ntfs()B= not -e $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 842 | $v = Cwd::abs_path( untaint_path( $v ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 842 | ▶ | is_win32() and defined $v and $v =~ s{ / }{\\}gmx; # More hate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&is_win32() and defined $v
MC/DC0%0/2
&is_win32() and defined $v
&is_win32()
defined $v
Truth table33%1/3
A and B
A= &is_win32()B= defined $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 842 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 93 | ▶ | sub app_prefix ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
app_prefix: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 93 | ▶ | (my $v = lc ($_[ 0 ] // q())) =~ s{ :: }{_}gmx; return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0] // ""
MC/DC100%1/1
$_[0] // ""
$_[0]
Truth table100%2/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 364 | ▶ | sub arg_list (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_list: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 364 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'HASH' ? { %{ $_[ 0 ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$_[0] and ref $_[0] eq "HASH"
MC/DC100%2/2
$_[0] and ref $_[0] eq "HASH"
$_[0]
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | : $_[ 0 ] ? { @_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 212 | ▶ | sub assert_directory ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert_directory: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 212 | my $v = abs_path( $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 212 | ▶ | defined $v and length $v and -d "${v}" and return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $v and length $v and -d "$v"
defined $v and length $v
MC/DC100%3/3
defined $v and length $v and -d "$v"
defined $v
length $v
-d "$v"
Truth table100%4/4
A and B and C
A= defined $vB= length $vC= -d "$v"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 211 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | sub base64_decode_ns ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base64_decode_ns: called CC=13 SCAR=27.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | ▶ | my $x = shift; defined $x or return; my @x = split q(), $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | my $index = $_index64->(); my $j = 0; my $k = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | my $len = length $x; my $pad = 64; my @y = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ROUND: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | while ($j < $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 10 | my @c = (); my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 10 | ▶ | while ($i < 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 40 | my $uc = $index->[ ord $x[ $j++ ] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 40 | ▶ | $uc ne 'XX' and $c[ $i++ ] = 0 + $uc; $j == $len or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | ▶ | if ($i < 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $i < 2 and last ROUND; $i == 2 and $c[ 2 ] = $pad; $c[ 3 ] = $pad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 10 | ▶ | ($c[ 0 ] == $pad || $c[ 1 ] == $pad) and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$c[0] == $pad or $c[1] == $pad
MC/DC0%0/2
$c[0] == $pad or $c[1] == $pad
$c[0] == $pad
$c[1] == $pad
Truth table33%1/3
A or B
A= $c[0] == $padB= $c[1] == $pad
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 10 | $y[ $k++ ] = ( $c[ 0 ] << 2) | (($c[ 1 ] & 0x30) >> 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 10 | ▶ | $c[ 2 ] == $pad and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 10 | $y[ $k++ ] = (($c[ 1 ] & 0x0F) << 4) | (($c[ 2 ] & 0x3C) >> 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 10 | ▶ | $c[ 3 ] == $pad and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 9 | $y[ $k++ ] = (($c[ 2 ] & 0x03) << 6) | $c[ 3 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 2 | return join q(), map { chr $_ } @y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | ▶ | sub base64_encode_ns (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base64_encode_ns: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | ▶ | my $x = shift; defined $x or return; my @x = split q(), $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | my $basis = $_base64_char_set->(); my $len = length $x; my @y = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | ▶ | for (my $i = 0, my $j = 0; $len > 0; $len -= 3, $i += 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 10 | ▶ | my $c1 = ord $x[ $i ]; my $c2 = $len > 1 ? ord $x[ $i + 1 ] : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 10 | $y[ $j++ ] = $basis->[ $c1 >> 2 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 10 | $y[ $j++ ] = $basis->[ (($c1 & 0x3) << 4) | (($c2 & 0xF0) >> 4) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 10 | ▶ | if ($len > 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 9 | my $c3 = ord $x[ $i + 2 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 9 | $y[ $j++ ] = $basis->[ (($c2 & 0xF) << 2) | (($c3 & 0xC0) >> 6) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 9 | $y[ $j++ ] = $basis->[ $c3 & 0x3F ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | elsif ($len == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | $y[ $j++ ] = $basis->[ ($c2 & 0xF) << 2 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | $y[ $j++ ] = $basis->[ 64 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | else { # len == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $y[ $j++ ] = $basis->[ 64 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $y[ $j++ ] = $basis->[ 64 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | return join q(), @y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | ▶ | sub bsonid (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsonid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | return unpack 'H*', $_bsonid->( $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | sub bsonid_time ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsonid_time: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | return unpack 'N', substr hex2str( $_[ 0 ] ), 0, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | ▶ | sub bson64id (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bson64id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | return base64_encode_ns( $_bsonid->( 2 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | sub bson64id_time ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bson64id_time: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | return unpack 'N', substr base64_decode_ns( $_[ 0 ] ), 2, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 58 | ▶ | sub canonicalise ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalise: called CC=5 SCAR=17.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 58 | my ($base, $relpath) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $base = is_arrayref( $base ) ? catdir( @{ $base } ) : $base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 58 | ▶ | $relpath or return canonpath( untaint_path( $base ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | my @relpath = is_arrayref( $relpath ) ? @{ $relpath } : $relpath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 33 | my $path = canonpath( untaint_path( catdir( $base, @relpath ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 33 | ▶ | -d $path and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 33 | return canonpath( untaint_path( catfile( $base, @relpath ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 49 | ▶ | sub class2appdir ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class2appdir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 49 | return lc distname( $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 22 | ▶ | sub classdir ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classdir: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 22 | ▶ | return catdir( split m{ :: }mx, $_[ 0 ] // q() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 56 | ▶ | sub classfile ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classfile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 56 | return catfile( split m{ :: }mx, $_[ 0 ].'.pm' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 10 | ▶ | sub create_token (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_token: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 10 | ▶ | return digest( $_[ 0 ] // urandom() )->hexdigest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_[0] // &urandom()
MC/DC0%0/2
$_[0] // &urandom()
$_[0]
&urandom()
Truth table66%2/3
A // B
A= $_[0]B= &urandom()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub create_token64 (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_token64: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | return digest( $_[ 0 ] // urandom() )->b64digest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0] // &urandom()
MC/DC0%0/2
$_[0] // &urandom()
$_[0]
&urandom()
Truth table0%0/3
A // B
A= $_[0]B= &urandom()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | sub cwdp () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cwdp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | return abs_path( curdir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 4 | ▶ | sub dash2under (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dash2under: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 4 | ▶ | (my $v = $_[ 0 ] // q()) =~ s{ [\-] }{_}gmx; return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2 | ▶ | sub data_dumper (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_dumper: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | _data_dumper( @_ ); return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 10 | ▶ | sub digest ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
digest: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 10 | my $seed = shift; my ($candidate, $digest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 10 | ▶ | if ($digest_cache) { $digest = Digest->new( $digest_cache ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 3 | for (DIGEST_ALGORITHMS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 3 | ▶ | $candidate = $_; $digest = eval { Digest->new( $candidate ) } and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 3 | ▶ | $digest or throw( 'Digest algorithm not found' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 3 | $digest_cache = $candidate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 10 | $digest->add( $seed ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 10 | return $digest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 50 | ▶ | sub distname ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
distname: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 50 | ▶ | (my $v = $_[ 0 ] // q()) =~ s{ :: }{-}gmx; return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | #head2 downgrade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # $sv_pv = downgrade $sv_pvgv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | #Horrendous Perl bug is promoting C<PV> and C<PVMG> type scalars to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | #C<PVGV>. Serializing these values with L<Storable> throws a can't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | #store SCALAR items error. This functions copies the string value of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | #the input scalar to the output scalar but resets the output scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | #type to C<PV> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | #sub downgrade (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # my $x = shift // q(); my ($y) = $x =~ m{ (.*) }msx; return $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | sub elapsed () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elapsed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | return time - $BASETIME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 10 | ▶ | sub emit (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 10 | ▶ | my @args = @_; $args[ 0 ] //= q(); chomp( @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args[0] //= ""
MC/DC100%1/1
$args[0] //= ""
$args[0]
Truth table100%2/2
A
A= $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 10 | local ($OFS, $ORS) = ("\n", "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 10 | ▶ | return openhandle *STDOUT ? emit_to( *STDOUT, @args ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | ▶ | sub emit_err (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_err: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | ▶ | my @args = @_; $args[ 0 ] //= q(); chomp( @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args[0] //= ""
MC/DC0%0/1
$args[0] //= ""
$args[0]
Truth table50%1/2
A
A= $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | local ($OFS, $ORS) = ("\n", "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | ▶ | return openhandle *STDERR ? emit_to( *STDERR, @args ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 28 | ▶ | sub emit_to ($;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_to: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 28 | my ($handle, @args) = @_; local $OS_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 28 | ▶ | return (print {$handle} @args or throw( 'IO error: [_1]', [ $OS_ERROR ] )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
print({$handle;} @args) || &throw('IO error: [_1]', [$Class::Usul::Functions::OS_ERROR])
MC/DC0%0/2
print({$handle;} @args) || &throw('IO error: [_1]', [$Class::Usul::Functions::OS_ERROR])
print({$handle;} @args)
&throw('IO error: [_1]', [$Class::Usul::Functions::OS_ERROR])
Truth table33%1/3
A || B
A= print({$handle;} @args)B= &throw('IO error: [_1]', [$Class::Usul::Functions::OS_ERROR])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 17 | ▶ | sub ensure_class_loaded ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_class_loaded: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 17 | ▶ | my ($class, $opts) = @_; $opts //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts //= {}
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 17 | ▶ | $class or throw( Unspecified, [ 'class name' ], level => 2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 17 | ▶ | is_module_name( $class ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | or throw( 'String [_1] invalid classname', [ $class ], level => 2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 17 | ▶ | not $opts->{ignore_loaded} and is_class_loaded( $class ) and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $opts->{"ignore_loaded"} and &is_class_loaded($class)
MC/DC50%1/2
not $opts->{"ignore_loaded"} and &is_class_loaded($class)
not $opts->{"ignore_loaded"}
&is_class_loaded($class)
Truth table66%2/3
not(A) and B
A= not $opts->{"ignore_loaded"}B= &is_class_loaded($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 9 | eval { require_module( $class ) }; throw_on_error( { level => 3 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 8 | ▶ | is_class_loaded( $class ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | or throw( 'Class [_1] loaded but package undefined', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | [ $class ], level => 2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 49 | ▶ | sub env_prefix ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
env_prefix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 49 | return uc app_prefix( $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | ▶ | sub escape_TT (;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_TT: called CC=6 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | ▶ | my $v = defined $_[ 0 ] ? $_[ 0 ] : q(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | ▶ | my $fl = ($_[ 1 ] && $_[ 1 ]->[ 0 ]) || '<'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$_[1] && $_[1][0] || '<'
$_[1] and $_[1][0]
MC/DC0%0/2
$_[1] && $_[1][0] || '<'
$_[1]
$_[1][0]
Truth table33%1/3
A and B
A= $_[1]B= $_[1][0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | ▶ | my $fr = ($_[ 1 ] && $_[ 1 ]->[ 1 ]) || '>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$_[1] && $_[1][1] || '>'
$_[1] and $_[1][1]
MC/DC0%0/2
$_[1] && $_[1][1] || '>'
$_[1]
$_[1][1]
Truth table33%1/3
A and B
A= $_[1]B= $_[1][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 1 | $v =~ s{ \[\% }{${fl}%}gmx; $v =~ s{ \%\] }{%${fr}}gmx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 1 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 8 | ▶ | sub exception (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exception: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 8 | return EXCEPTION_CLASS->caught( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 21 | ▶ | sub find_apphome ($;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_apphome: called CC=14 SCAR=28.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 21 | my ($appclass, $default, $extns) = @_; my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # 0. Pass the directory in (short circuit the search) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 21 | ▶ | $path = assert_directory $default and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 21 | my $app_pref = app_prefix $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 21 | my $appdir = class2appdir $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 21 | my $classdir = classdir $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 21 | my $env_pref = env_prefix $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 21 | my $my_home = File::HomeDir->my_home; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # 1a. Environment variable - for application directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 21 | ▶ | $path = assert_directory $ENV{ "${env_pref}_HOME" } and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # 1b. Environment variable - for config file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 21 | ▶ | $path = $_get_env_var_for_conf->( "${env_pref}_CONFIG" ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # 2a. Users XDG_DATA_HOME env variable or XDG default share directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 21 | ▶ | $path = $ENV{ 'XDG_DATA_HOME' } // catdir( $my_home, '.local', 'share' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{"XDG_DATA_HOME"} // catdir($my_home, ".local", "share")
MC/DC0%0/2
$ENV{"XDG_DATA_HOME"} // catdir($my_home, ".local", "share")
$ENV{"XDG_DATA_HOME"}
catdir($my_home, ".local", "share")
Truth table33%1/3
A // B
A= $ENV{"XDG_DATA_HOME"}B= catdir($my_home, ".local", "share")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 21 | ▶ | $path = assert_directory catdir( $path, $appdir ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # 2b. Users home directory - dot file containing shell env variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 21 | ▶ | $path = $_get_file_var->( $my_home, $app_pref, $classdir ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 21 | ▶ | $path = $_get_file_var->( $my_home, $appdir, $classdir ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # 2c. Users home directory - dot directory is apphome | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 21 | $path = catdir( $my_home, ".${app_pref}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 21 | ▶ | $path = assert_directory $path and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 21 | $path = catdir( $my_home, ".${appdir}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 21 | ▶ | $path = assert_directory $path and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # 3. Well known path containing shell env file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 21 | ▶ | $path = $_get_known_file_var->( $appdir, $classdir ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # 4. Default install prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 21 | $path = catdir( @{ PREFIX() }, $appdir, 'default', 'lib', $classdir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 21 | ▶ | $path = assert_directory $path and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # 5a. Config file found in @INC - underscore as separator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 21 | ▶ | $path = $_find_cfg_in_inc->( $classdir, $app_pref, $extns ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # 5b. Config file found in @INC - dash as separator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 21 | ▶ | $path = $_find_cfg_in_inc->( $classdir, $appdir, $extns ) and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # 6. Default to /tmp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 21 | return untaint_path( DEFAULT_CONFHOME ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 55 | ▶ | sub find_source ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_source: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 55 | my $class = shift; my $file = classfile( $class ); my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 55 | for (@INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 165 | ▶ | $path = abs_path( catfile( $_, $file ) ) and -f $path and return $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$path = &abs_path(scalar catfile($_, $file)) and -f $path
MC/DC50%1/2
$path = &abs_path(scalar catfile($_, $file)) and -f $path
$path = &abs_path(scalar catfile($_, $file))
-f $path
Truth table66%2/3
A and B
A= $path = &abs_path(scalar catfile($_, $file))B= -f $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | ▶ | sub first_char ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_char: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | return substr $_[ 0 ], 0, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | sub fqdn (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fqdn: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | my $x = shift // hostname; return (gethostbyname( $x ))[ 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() // hostname()
MC/DC0%0/2
shift() // hostname()
shift()
hostname()
Truth table0%0/3
A // B
A= shift()B= hostname()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | sub fullname () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fullname: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | my $v = (split m{ \s* , \s * }msx, (get_user()->gecos // q()))[ 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&get_user()->gecos // ""
MC/DC0%0/1
&get_user()->gecos // ""
&get_user()->gecos
Truth table0%0/2
A
A= &get_user()->gecos
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | $v //= q(); $v =~ s{ [\&] }{}gmx; # Coz af25e158-d0c7-11e3-bdcb-31d9eda79835 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$v //= ""
MC/DC0%0/1
$v //= ""
$v
Truth table0%0/2
A
A= $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | return untaint_cmdline( $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 21 | ▶ | sub get_cfgfiles ($;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cfgfiles: called CC=10 SCAR=24.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 21 | my ($appclass, $dirs, $extns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 21 | ▶ | $appclass // throw( Unspecified, [ 'application class' ], level => 2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$appclass // &throw(Unspecified(), ["application class"], "level", 2)
MC/DC0%0/2
$appclass // &throw(Unspecified(), ["application class"], "level", 2)
$appclass
&throw(Unspecified(), ["application class"], "level", 2)
Truth table33%1/3
A // B
A= $appclassB= &throw(Unspecified(), ["application class"], "level", 2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 21 | ▶ | is_arrayref( $dirs ) or $dirs = [ $dirs || curdir ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$dirs || '.'
MC/DC0%0/1
$dirs || '.'
$dirs
Truth table50%1/2
A
A= $dirs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 21 | my $app_pref = app_prefix $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 21 | my $appdir = class2appdir $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 21 | my $env_pref = env_prefix $appclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 21 | ▶ | my $suffix = $ENV{ "${env_pref}_CONFIG_LOCAL_SUFFIX" } // '_local'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"${env_pref}_CONFIG_LOCAL_SUFFIX"} // "_local"
MC/DC0%0/1
$ENV{"${env_pref}_CONFIG_LOCAL_SUFFIX"} // "_local"
$ENV{"${env_pref}_CONFIG_LOCAL_SUFFIX"}
Truth table50%1/2
A
A= $ENV{"${env_pref}_CONFIG_LOCAL_SUFFIX"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 21 | my @paths = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 21 | for my $dir (@{ $dirs }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 21 | ▶ | for my $extn (@{ $extns // [ supported_extensions() ] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$extns // [&supported_extensions()]
MC/DC0%0/1
$extns // [&supported_extensions()]
$extns
Truth table50%1/2
A
A= $extns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 25 | for my $path (map { $_catpath->( $dir, $_ ) } "${app_pref}${extn}", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | "${appdir}${extn}", "${app_pref}${suffix}${extn}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | "${appdir}${suffix}${extn}") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 100 | ▶ | -f $path and push @paths, $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 21 | return \@paths; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 6 | ▶ | sub get_user (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_user: called CC=5 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 6 | ▶ | my $user = shift; is_win32() and return Class::Null->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 6 | ▶ | defined $user and $user !~ m{ \A \d+ \z }mx and return getpwnam( $user ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $user and not $user =~ / \A \d+ \z /mx
MC/DC0%0/2
defined $user and not $user =~ / \A \d+ \z /mx
defined $user
not $user =~ / \A \d+ \z /mx
Truth table33%1/3
A and not(B)
A= defined $userB= not $user =~ / \A \d+ \z /mx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 6 | ▶ | return getpwuid( $user // $UID ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$user // $Class::Usul::Functions::UID
MC/DC50%1/2
$user // $Class::Usul::Functions::UID
$user
$Class::Usul::Functions::UID
Truth table66%2/3
A // B
A= $userB= $Class::Usul::Functions::UID
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 2 | ▶ | sub hex2str (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hex2str: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 2 | ▶ | my @a = split m{}mx, shift // q(); my $str = q(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 2 | ▶ | while (my ($x, $y) = splice @a, 0, 2) { $str .= pack 'C', hex "${x}${y}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 7 | ▶ | sub home2appldir ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
home2appldir: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 7 | ▶ | $_[ 0 ] or return; my $dir = io( $_[ 0 ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 6 | ▶ | $dir = $dir->parent while ($dir ne $dir->parent and $dir !~ m{ lib \z }mx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$dir ne $dir->parent and not $dir =~ / lib \z /mx
MC/DC100%2/2
$dir ne $dir->parent and not $dir =~ / lib \z /mx
$dir ne $dir->parent
not $dir =~ / lib \z /mx
Truth table100%3/3
A and not(B)
A= $dir ne $dir->parentB= not $dir =~ / lib \z /mx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 6 | ▶ | return $dir ne $dir->parent ? $dir->parent : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 200 | ▶ | sub io (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
io: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 200 | return File::DataClass::IO->new( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 2501 | ▶ | sub is_arrayref (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_arrayref: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 2501 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'ARRAY' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "ARRAY"
MC/DC100%2/2
$_[0] and ref $_[0] eq "ARRAY"
$_[0]
ref $_[0] eq "ARRAY"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 56 | ▶ | sub is_coderef (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_coderef: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 56 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'CODE' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "CODE"
MC/DC100%2/2
$_[0] and ref $_[0] eq "CODE"
$_[0]
ref $_[0] eq "CODE"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 418 | ▶ | sub is_hashref (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hashref: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 418 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "HASH"
MC/DC100%2/2
$_[0] and ref $_[0] eq "HASH"
$_[0]
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 491 | ▶ | sub is_member (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_member: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 491 | ▶ | my ($candidate, @args) = @_; $candidate or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 491 | ▶ | is_arrayref $args[ 0 ] and @args = @{ $args[ 0 ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 491 | ▶ | return (first { $_ eq $candidate } @args) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 842 | ▶ | sub is_ntfs () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ntfs: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 842 | ▶ | return is_win32() || lc $OSNAME eq 'cygwin' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&is_win32() or lc $Class::Usul::Functions::OSNAME eq "cygwin"
MC/DC0%0/2
&is_win32() or lc $Class::Usul::Functions::OSNAME eq "cygwin"
&is_win32()
lc $Class::Usul::Functions::OSNAME eq "cygwin"
Truth table33%1/3
A or B
A= &is_win32()B= lc $Class::Usul::Functions::OSNAME eq "cygwin"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2241 | ▶ | sub is_win32 () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_win32: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 2241 | ▶ | return lc $OSNAME eq 'mswin32' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | sub list_attr_of ($;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_attr_of: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | my ($obj, @except) = @_; my $class = blessed $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | ensure_class_loaded( 'Pod::Eventual::Simple' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 1 | ▶ | is_member 'new', @except or push @except, 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 45 | return map { my $attr = $_->[0]; [ @{ $_ }, $obj->$attr ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 45 | map { [ $_->[1], $_->[0], $_get_pod_content_for_attr->( @{ $_ } ) ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 50 | ▶ | grep { $_->[0] ne 'Moo::Object' and not is_member $_->[1], @except } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->[0] ne 'Moo::Object' && !&is_member($_->[1], @except)
MC/DC100%2/2
$_->[0] ne 'Moo::Object' && !&is_member($_->[1], @except)
$_->[0] ne 'Moo::Object'
!&is_member($_->[1], @except)
Truth table100%3/3
A && not(B)
A= $_->[0] ne 'Moo::Object'B= !&is_member($_->[1], @except)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 50 | map { m{ \A (.+) \:\: ([^:]+) \z }mx; [ $1, $2 ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | @{ Class::Inspector->methods( $class, 'full', 'public' ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 6 | ▶ | sub loginid (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loginid: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 6 | ▶ | return untaint_cmdline( get_user( $_[ 0 ] )->name || 'unknown' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
&get_user($_[0])->name || 'unknown'
MC/DC0%0/1
&get_user($_[0])->name || 'unknown'
&get_user($_[0])->name
Truth table50%1/2
A
A= &get_user($_[0])->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 5 | ▶ | sub logname (;$) { # Deprecated use loginid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logname: called CC=3 SCAR=15.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 5 | ▶ | return untaint_cmdline( $ENV{USER} || $ENV{LOGNAME} || loginid( $_[ 0 ] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$ENV{'USER'} || $ENV{'LOGNAME'} || &loginid($_[0])
$ENV{"USER"} or $ENV{"LOGNAME"}
MC/DC0%0/3
$ENV{'USER'} || $ENV{'LOGNAME'} || &loginid($_[0])
$ENV{"USER"}
$ENV{"LOGNAME"}
&loginid($_[0])
Truth table25%1/4
A or B || C
A= $ENV{"USER"}B= $ENV{"LOGNAME"}C= &loginid($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 47 | ▶ | sub merge_attributes ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_attributes: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 47 | my ($dest, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 47 | ▶ | my $attr = is_arrayref( $args[ -1 ] ) ? pop @args : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 47 | ▶ | for my $k (grep { not exists $dest->{ $_ } or not defined $dest->{ $_ } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $dest->{$_} && defined $dest->{$_}
MC/DC50%1/2
exists $dest->{$_} && defined $dest->{$_}
exists $dest->{$_}
defined $dest->{$_}
Truth table66%2/3
A && B
A= exists $dest->{$_}B= defined $dest->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 47 | @{ $attr }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 171 | my $i = 0; my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 171 | ▶ | while (not defined $v and defined( my $src = $args[ $i++ ] )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $v and defined(my $src = $args[$i++])
MC/DC100%2/2
not defined $v and defined(my $src = $args[$i++])
not defined $v
defined(my $src = $args[$i++])
Truth table100%3/3
not(A) and B
A= not defined $vB= defined(my $src = $args[$i++])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 201 | my $class = blessed $src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 201 | ▶ | $v = $class ? ($src->can( $k ) ? $src->$k() : undef) : $src->{ $k }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 171 | ▶ | defined $v and $dest->{ $k } = $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 47 | return $dest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 2 | ▶ | sub my_prefix (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
my_prefix: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | ▶ | return split_on__( basename( $_[ 0 ] // q(), PERL_EXTNS ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 384 | ▶ | sub nonblocking_write_pipe_pair () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nonblocking_write_pipe_pair: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 384 | ▶ | my ($r, $w); pipe $r, $w or throw( 'No pipe' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 384 | fcntl $w, F_SETFL, O_NONBLOCK; $w->autoflush( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 384 | binmode $r; binmode $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 384 | return [ $r, $w ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 6 | ▶ | sub ns_environment ($$;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ns_environment: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 6 | my ($class, $k, $v) = @_; $k = (env_prefix $class).'_'.(uc $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 6 | ▶ | return defined $v ? $ENV{ $k } = $v : $ENV{ $k }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 7 | ▶ | sub pad ($$;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pad: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 7 | my ($v, $wanted, $str, $direction) = @_; my $len = $wanted - length $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 7 | ▶ | $len > 0 or return $v; (defined $str and length $str) or $str = q( ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $str and length $str
MC/DC50%1/2
defined $str and length $str
defined $str
length $str
Truth table66%2/3
A and B
A= defined $strB= length $str
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 6 | my $pad = substr( $str x $len, 0, $len ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 6 | ▶ | (not $direction or $direction eq 'right') and return $v.$pad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $direction or $direction eq "right"
MC/DC100%2/2
not $direction or $direction eq "right"
not $direction
$direction eq "right"
Truth table100%3/3
not(A) or B
A= not $directionB= $direction eq "right"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 2 | ▶ | $direction eq 'left' and return $pad.$v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 1 | return (substr $pad, 0, int( (length $pad) / 2 )).$v | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | .(substr $pad, 0, int( 0.99999999 + (length $pad) / 2 )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | ▶ | sub prefix2class (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix2class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | return join '::', map { ucfirst } split m{ - }mx, my_prefix( $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | ▶ | sub socket_pair () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socket_pair: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | my $rdr = gensym; my $wtr = gensym; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | ▶ | socketpair( $rdr, $wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | or throw( $EXTENDED_OS_ERROR ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 1 | shutdown ( $rdr, 1 ); # No more writing for reader | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | shutdown ( $wtr, 0 ); # No more reading for writer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | return [ $rdr, $wtr ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 11 | ▶ | sub split_on__ (;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_on__: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 11 | ▶ | return (split m{ _ }mx, $_[ 0 ] // q())[ $_[ 1 ] // 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$_[1] // 0
$_[0] // ""
MC/DC100%1/1
$_[1] // 0
$_[1]
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table100%2/2
A
A= $_[1]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 9 | ▶ | sub split_on_dash (;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_on_dash: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 9 | ▶ | return (split m{ \- }mx, $_[ 0 ] // q())[ $_[ 1 ] // 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$_[1] // 0
$_[0] // ""
MC/DC0%0/1
$_[1] // 0
$_[1]
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[1]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 46 | ▶ | sub squeeze (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
squeeze: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 46 | ▶ | (my $v = $_[ 0 ] // q()) =~ s{ \s+ }{ }gmx; return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 612 | ▶ | sub strip_leader (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strip_leader: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 612 | ▶ | (my $v = $_[ 0 ] // q()) =~ s{ \A [^:]+ [:] \s+ }{}msx; return $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 1 | ▶ | sub sub_name (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sub_name: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | ▶ | my $frame = 1 + ($_[ 0 ] // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] // 0
MC/DC0%0/1
$_[0] // 0
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 1 | ▶ | return (split m{ :: }mx, ((caller $frame)[ 3 ]) // 'main')[ -1 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
(caller $frame)[3] // "main"
MC/DC0%0/1
(caller $frame)[3] // "main"
(caller $frame)[3]
Truth table50%1/2
A
A= (caller $frame)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 3 | ▶ | sub symlink (;$$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symlink: called CC=9 SCAR=23.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 3 | my ($from, $to, $base) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 3 | ▶ | defined $base and not CORE::length $base and $base = File::Spec->rootdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $base and not length $base
MC/DC0%0/2
defined $base and not length $base
defined $base
not length $base
Truth table66%2/3
A and not(B)
A= defined $baseB= not length $base
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 3 | ▶ | $from or throw( Unspecified, [ 'path from' ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 3 | $from = io( $from )->absolute( $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 3 | ▶ | $from->exists or throw( PathNotFound, [ "${from}" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 3 | ▶ | $to or throw( Unspecified, [ 'path to' ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 3 | ▶ | $to = io( $to )->absolute( $base ); $to->is_link and $to->unlink; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 3 | ▶ | $to->exists and throw( PathAlreadyExists, [ "${to}" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 3 | ▶ | CORE::symlink "${from}", "${to}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | or throw( 'Symlink from [_1] to [_2] failed: [_3]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | [ "${from}", "${to}", $OS_ERROR ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 3 | return "Symlinked ${from} to ${to}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 1 | ▶ | sub thread_id () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
thread_id: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1 | ▶ | return exists $INC{ 'threads.pm' } ? threads->tid() : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 170 | ▶ | sub throw (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 170 | EXCEPTION_CLASS->throw( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 9 | ▶ | sub throw_on_error (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw_on_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 9 | EXCEPTION_CLASS->throw_on_error( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | ▶ | sub trim (;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | ▶ | my $chs = $_[ 1 ] // " \t"; (my $v = $_[ 0 ] // q()) =~ s{ \A [$chs]+ }{}mx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$_[1] // " \t"
$_[0] // ""
MC/DC100%1/1
$_[1] // " \t"
$_[1]
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table100%2/2
A
A= $_[1]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 2 | chomp $v; $v =~ s{ [$chs]+ \z }{}mx; return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | ▶ | sub unescape_TT (;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unescape_TT: called CC=6 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | ▶ | my $v = defined $_[ 0 ] ? $_[ 0 ] : q(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1 | ▶ | my $fl = ($_[ 1 ] && $_[ 1 ]->[ 0 ]) || '<'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$_[1] && $_[1][0] || '<'
$_[1] and $_[1][0]
MC/DC0%0/2
$_[1] && $_[1][0] || '<'
$_[1]
$_[1][0]
Truth table33%1/3
A and B
A= $_[1]B= $_[1][0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | ▶ | my $fr = ($_[ 1 ] && $_[ 1 ]->[ 1 ]) || '>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$_[1] && $_[1][1] || '>'
$_[1] and $_[1][1]
MC/DC0%0/2
$_[1] && $_[1][1] || '>'
$_[1]
$_[1][1]
Truth table33%1/3
A and B
A= $_[1]B= $_[1][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | $v =~ s{ ${fl}\% }{[%}gmx; $v =~ s{ \%${fr} }{%]}gmx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 1 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 58 | ▶ | sub untaint_cmdline (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_cmdline: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 58 | return untaint_string( UNTAINT_CMDLINE, $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 16 | ▶ | sub untaint_identifier (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_identifier: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 16 | return untaint_string( UNTAINT_IDENTIFIER, $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 1276 | ▶ | sub untaint_path (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 1276 | return untaint_string( UNTAINT_PATH, $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 1350 | ▶ | sub untaint_string ($;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
untaint_string: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 1350 | my ($regex, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 1350 | ▶ | defined $string or return; length $string or return q(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 1337 | my ($untainted) = $string =~ $regex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 1337 | ▶ | (defined $untainted and $untainted eq $string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $untainted and $untainted eq $string
MC/DC50%1/2
defined $untainted and $untainted eq $string
defined $untainted
$untainted eq $string
Truth table66%2/3
A and B
A= defined $untaintedB= $untainted eq $string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | or throw( Tainted, [ $string ], level => 3 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 1333 | return $untainted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 2 | ▶ | sub urandom (;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
urandom: called CC=10 SCAR=32.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 2 | ▶ | my ($wanted, $opts) = @_; $wanted //= 64; $opts //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$wanted //= 64
$opts //= {}
MC/DC0%0/1
$wanted //= 64
$wanted
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $wanted
Truth table50%1/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 2 | ▶ | my $default = [ q(), 'dev', $OSNAME eq 'freebsd' ? 'random' : 'urandom' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 2 | ▶ | my $io = io( $opts->{source} // $default )->block_size( $wanted ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"source"} // $default
MC/DC0%0/2
$opts->{"source"} // $default
$opts->{"source"}
$default
Truth table33%1/3
A // B
A= $opts->{"source"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 2 | my $red; $io->exists and $io->is_readable and $red = $io->read | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 2 | ▶ | and $red == $wanted and return ${ $io->buffer }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$io->exists and $io->is_readable and $red = $io->read and $red == $wanted
$io->exists and $io->is_readable and $red = $io->read
$io->exists and $io->is_readable
MC/DC0%0/4
$io->exists and $io->is_readable and $red = $io->read and $red == $wanted
$io->exists
$io->is_readable
$red = $io->read
$red == $wanted
Truth table20%1/5
A and B and C and D
A= $io->existsB= $io->is_readableC= $red = $io->readD= $red == $wanted
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | my $res = q(); while (length $res < $wanted) { $res .= $_pseudo_random->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | return substr $res, 0, $wanted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | sub uuid (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | return io( $_[ 0 ] // UUID_PATH )->chomp->getline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[0] // &UUID_PATH()
MC/DC0%0/2
$_[0] // &UUID_PATH()
$_[0]
&UUID_PATH()
Truth table0%0/3
A // B
A= $_[0]B= &UUID_PATH()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 1 | ▶ | sub whiten ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
whiten: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 1 | my $v = unpack "b*", pop; my $pad = " \t" x 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 1 | $v =~ tr{01}{ \t}; $v =~ s{ (.{9}) }{$1\n}gmx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 1 | return "${pad}\n${v}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 1 | ▶ | sub zip (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zip: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 1 | my $p = @_ / 2; return @_[ map { $_, $_ + $p } 0 .. $p - 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | # Function composition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 1 | ▶ | sub chain (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 1 | ▶ | return (fold( sub { my ($x, $y) = @_; $x->$y } )->( shift ))->( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 3 | ▶ | sub compose (&;$) { # Was called build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compose: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 3 | ▶ | my ($f, $g) = @_; $g //= sub { @_ }; return sub { $f->( $g->( @_ ) ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition66%2/3
$g //= sub {
@_;
}
MC/DC0%0/2
$g //= sub {
@_;
}
$g
sub {
@_;
}
Truth table66%2/3
A //= B
A= $gB= sub {
@_;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 1 | ▶ | sub curry (&$;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
curry: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 1 | ▶ | my ($f, @args) = @_; return sub { $f->( @args, @_ ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 3 | ▶ | sub fold (&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fold: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 3 | my $f = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 3 | ▶ | return sub (;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 3 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 3 | ▶ | return sub (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 3 | ▶ | my $y = $x; $y = $f->( $y, shift ) while (@_); return $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 3 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 3 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 116 | ▶ | sub Y (&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Y: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 116 | ▶ | my $f = shift; return sub { $f->( Y( $f ) )->( @_ ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 1 | ▶ | sub factorial ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
factorial: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 5 | ▶ | return Y( sub (&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 5 | my $fac = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 5 | ▶ | return sub ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 5 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 1 | ▶ | return $n < 2 ? 1 : $n * $fac->( $n - 1 ) } } )->( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | ▶ | sub fibonacci ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fibonacci: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 109 | ▶ | return Y( sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 109 | my $fib = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 109 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 109 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 109 | ▶ | return $n == 0 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | : $n == 1 ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 1 | : $fib->( $n - 1 ) + $fib->( $n - 2 ) } } )->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 1 | ▶ | sub product (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
product: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 1 | ▶ | return ((fold { $_[ 0 ] * $_[ 1 ] })->( 1 ))->( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 1 | ▶ | sub sum (;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sum: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 1 | ▶ | return ((fold { $_[ 0 ] + $_[ 1 ] })->( 0 ))->( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 27 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||