| 1 | |||||||||||||||||||||
| 2 | package Apache2::ASP::ConfigFinder; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 25 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 25 | ▶ | use warnings 'all'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 25 | ▶ | use Cwd 'cwd'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 25 | our $CONFIGFILE = 'apache2-asp-config.xml'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | #============================================================================== | ||||||||||||||||||||
| 11 | sub config_path | ||||||||||||||||||||
| 12 | { | ||||||||||||||||||||
| 13 | 7 | ▶ | my $path = $CONFIGFILE; | ||||||||||||||||||
|
Subroutine
config_path: called CC=6 SCAR=28.1
Pod
documented
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 7 | ▶ | my $root = $ENV{DOCUMENT_ROOT} || cwd(); | ||||||||||||||||||
|
Condition33%1/3
$ENV{'DOCUMENT_ROOT'} || cwd()
MC/DC0%0/2
$ENV{'DOCUMENT_ROOT'} || cwd()
$ENV{'DOCUMENT_ROOT'}
cwd()
Truth table33%1/3
A || B
A= $ENV{'DOCUMENT_ROOT'}B= cwd()
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | # Try test dir: | ||||||||||||||||||||
| 18 | 7 | ▶ | if( -f "$root/t/conf/$CONFIGFILE" ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | { | ||||||||||||||||||||
| 20 | 7 | return "$root/t/conf/$CONFIGFILE"; | |||||||||||||||||||
| 21 | }# end if() | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # Start moving up: | ||||||||||||||||||||
| 24 | 0 | for( 1...10 ) | |||||||||||||||||||
| 25 | { | ||||||||||||||||||||
| 26 | 0 | my $path = "$root/conf/$CONFIGFILE"; | |||||||||||||||||||
| 27 | 0 | ▶ | return $path if -f $path; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 0 | ▶ | $root =~ s/\/[^\/]+$// | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | or last; | ||||||||||||||||||||
| 30 | }# end for() | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | die "CANNOT FIND '$CONFIGFILE' anywhere under '$root'"; | |||||||||||||||||||
| 33 | }# end config_path() | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 25 | 1;# return true: | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | __END__ | ||||||||||||||||||||