| 1 | package Config::Find; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | our $VERSION = '0.31'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | # selects implementation module: | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | our @ISA; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=11 SCAR=46.4
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | if ($^O=~/Win32/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | require Win32; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $OS = uc Win32::GetOSName(); | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | if ($OS=~/^WIN95/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | require Config::Find::Win95; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | @ISA=qw(Config::Find::Win95); | |||||||||||||||||||||||||||||||||||||||||
| 20 | } elsif ($OS=~/^WIN98/) { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | require Config::Find::Win98; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | @ISA=qw(Config::Find::Win98); | |||||||||||||||||||||||||||||||||||||||||
| 23 | } elsif ($OS=~/^WINME/) { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | require Config::Find::WinME; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | @ISA=qw(Config::Find::WinME); | |||||||||||||||||||||||||||||||||||||||||
| 26 | } elsif ($OS=~/^WINNT/) { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | require Config::Find::WinNT; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | @ISA=qw(Config::Find::WinNT); | |||||||||||||||||||||||||||||||||||||||||
| 29 | } elsif ($OS=~/^WIN2000/) { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | require Config::Find::Win2k; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | @ISA=qw(Config::Find::Win2k); | |||||||||||||||||||||||||||||||||||||||||
| 32 | } elsif ($OS=~/^WIN2003/) { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | require Config::Find::Win2k3; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | @ISA=qw(Config::Find::Win2k3); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } elsif ($OS=~/^WINXP/) { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | require Config::Find::WinXP; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | @ISA=qw(Config::Find::WinXP); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } elsif ($OS=~/^WINCE/) { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | require Config::Find::WinCE; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | @ISA=qw(Config::Find::WinCE); | |||||||||||||||||||||||||||||||||||||||||
| 41 | } elsif ($OS=~/^WIN7/) { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | require Config::Find::Win7; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | @ISA=qw(Config::Find::Win7); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # default to WinAny, and separate exceptions | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | require Config::Find::WinAny; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | @ISA=qw(Config::Find::WinAny); | |||||||||||||||||||||||||||||||||||||||||
| 48 | #croak "Unknown MSWin32 OS '$OS'"; | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | require Config::Find::Unix; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | @ISA=qw(Config::Find::Unix); | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | ▶ | sub find { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=4 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | my $class=shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 9 | my ($write, $global, $fn, @names)=$class->parse_opts(@_); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | ▶ | if (defined $fn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return ($write or -f $fn) ? $fn : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$write or -f $fn
MC/DC0%0/2
$write or -f $fn
$write
-f $fn
Truth table0%0/3
A or B
A= $writeB= -f $fn
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | $class->_find($write, $global, @names); | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub open { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $class=shift; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($write, $global, $fn, @names)=$class->parse_opts(@_); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | defined($fn) or $fn=$class->_find($write, $global, @names); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $class->_open($write, $global, $fn); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub install { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $class=shift; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $orig=shift; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($write, $global, $fn, @names)=$class->parse_opts( mode => 'w', @_); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | defined($fn) or $fn=$class->_find($write, $global, @names); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $class->_install($orig, $write, $global, $fn); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | ▶ | sub parse_opts { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_opts: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 9 | my ($class, %opts)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 9 | my $fn=$opts{file}; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 9 | my @names; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | ▶ | if (exists $opts{name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | @names=$opts{name}; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } elsif (exists $opts{names}) { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | UNIVERSAL::isa($opts{names}, 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | or croak "invalid argument for 'names', expecting an array ref"; | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | @names=@{$opts{names}} | |||||||||||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | @names=$class->guess_script_name(); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | my $write; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | ▶ | if (exists $opts{mode}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | if ($opts{mode}=~/^r(ead)?$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | # yes, do nothing! | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } elsif ($opts{mode}=~/w(rite)?$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | $write=1; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | croak "invalid option mode => '$opts{mode}'"; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | my $global; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | ▶ | if (exists $opts{scope}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | ▶ | if ($opts{scope}=~/^u(ser)?$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | # yes, do nothing! | ||||||||||||||||||||||||||||||||||||||||||
| 109 | } elsif ($opts{scope}=~/g(lobal)?$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | $global=1; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | croak "invalid option scope => '$opts{scope}'"; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 6 | return ($write, $global, $fn, @names) | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | __END__ | ||||||||||||||||||||||||||||||||||||||||||