| 1 | package YATT::Util::CmdLine; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | BEGIN {require Exporter; *import = \&Exporter::import} | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | our @EXPORT_OK = qw(parse_opts parse_params); | |||||||||||||||||||||||||||
| 8 | 3 | our @EXPORT = @EXPORT_OK; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # posix style option. | ||||||||||||||||||||||||||||
| 11 | 4 | ▶ | sub parse_opts { | ||||||||||||||||||||||||||
|
Subroutine
parse_opts: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 4 | my ($pack, $list, $result) = @_; | |||||||||||||||||||||||||||
| 13 | 4 | my $wantarray = wantarray; | |||||||||||||||||||||||||||
| 14 | 4 | ▶ | unless (defined $result) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | $result = $wantarray ? [] : {}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | 4 | ▶ | while (@$list | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$list and () = $list->[0] =~ /^--(?:([\w\.\-]+)(?:=(.*))?)?/
MC/DC100%2/2
@$list and () = $list->[0] =~ /^--(?:([\w\.\-]+)(?:=(.*))?)?/
@$list
() = $list->[0] =~ /^--(?:([\w\.\-]+)(?:=(.*))?)?/
Truth table100%3/3
A and B
A= @$listB= () = $list->[0] =~ /^--(?:([\w\.\-]+)(?:=(.*))?)?/
| |||||||||||||||||||||||||||||
| 18 | and my ($n, $v) = $list->[0] =~ /^--(?:([\w\.\-]+)(?:=(.*))?)?/) { | ||||||||||||||||||||||||||||
| 19 | 10 | shift @$list; | |||||||||||||||||||||||||||
| 20 | 10 | ▶ | last unless defined $n; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 8 | ▶ | $v = 1 unless defined $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 8 | ▶ | if (ref $result eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | $result->{$n} = $v; | |||||||||||||||||||||||||||
| 24 | } else { | ||||||||||||||||||||||||||||
| 25 | 6 | push @$result, $n, $v; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 4 | ▶ | $wantarray && ref $result ne 'HASH' ? @$result : $result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$wantarray and ref $result ne "HASH"
MC/DC50%1/2
$wantarray and ref $result ne "HASH"
$wantarray
ref $result ne "HASH"
Truth table66%2/3
A and B
A= $wantarrayB= ref $result ne "HASH"
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # 'Make' style parameter. | ||||||||||||||||||||||||||||
| 32 | 3 | ▶ | sub parse_params { | ||||||||||||||||||||||||||
|
Subroutine
parse_params: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 3 | my ($pack, $list, $hash) = @_; | |||||||||||||||||||||||||||
| 34 | 3 | my $explicit; | |||||||||||||||||||||||||||
| 35 | 3 | ▶ | unless (defined $hash) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 2 | $hash = {} | |||||||||||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||||||||||
| 38 | 1 | $explicit++; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 3 | ▶ | for (; @$list and $list->[0] =~ /^([^=]+)=(.*)/; shift @$list) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$list and $list->[0] =~ /^([^=]+)=(.*)/
MC/DC50%1/2
@$list and $list->[0] =~ /^([^=]+)=(.*)/
@$list
$list->[0] =~ /^([^=]+)=(.*)/
Truth table66%2/3
A and B
A= @$listB= $list->[0] =~ /^([^=]+)=(.*)/
| |||||||||||||||||||||||||||||
| 41 | 2 | $hash->{$1} = $2; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 3 | ▶ | if (not $explicit and wantarray) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $explicit and wantarray
MC/DC100%2/2
not $explicit and wantarray
not $explicit
wantarray
Truth table100%3/3
not(A) and B
A= not $explicitB= wantarray
| |||||||||||||||||||||||||||||
| 44 | # return empty list if hash is empty | ||||||||||||||||||||||||||||
| 45 | 1 | ▶ | %$hash ? $hash : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||
| 47 | 2 | $hash | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 3 | 1; | |||||||||||||||||||||||||||