version 1.13, 2006/09/15 20:49:27
|
version 1.14, 2007/08/30 20:19:35
|
Line 58 sub read_conf {
|
Line 58 sub read_conf {
|
if ($configdir eq '') { |
if ($configdir eq '') { |
die("Couldn't find a directory containing $filename"); |
die("Couldn't find a directory containing $filename"); |
} |
} |
open(CONFIG,'<'.$configdir.$filename) or |
&process_file($configdir.$filename,\%perlvar); |
die("Can't read $configdir$filename"); |
if ($filename eq 'loncapa_apache.conf') { |
while (my $configline=<CONFIG>) { |
my @files = glob($configdir.'loncapa_apache_local*.conf'); |
if ($configline =~ /^[^\#]*PerlSetVar/) { |
foreach my $file (@files) { |
my ($unused,$varname,$varvalue)=split(/\s+/,$configline); |
&process_file($file,\%perlvar); |
chomp($varvalue); |
|
$perlvar{$varname}=$varvalue; |
|
} |
} |
} |
} |
close(CONFIG); |
|
} |
} |
my $perlvarref=\%perlvar; |
return (\%perlvar); |
return ($perlvarref); |
} |
|
|
|
# --------------- Subroutine process_file: helper routine |
|
# This subroutine does the actual file reading and reads PerlSetVar discovery |
|
# specified file, arguments are the filename and a ref to a hash to |
|
# place the values in |
|
sub process_file { |
|
my ($file,$perlvar) = @_; |
|
open(my $config,'<',$file) or |
|
die("Can't read $file"); |
|
while (my $configline=<$config>) { |
|
if ($configline =~ /^[^\#]*PerlSetVar/) { |
|
my ($unused,$varname,$varvalue)=split(/\s+/,$configline); |
|
chomp($varvalue); |
|
$perlvar->{$varname}=$varvalue; |
|
} |
|
} |
|
close($config); |
} |
} |
|
|
#---------------------- Subroutine read_hosts: Read a LON-CAPA hosts.tab |
#---------------------- Subroutine read_hosts: Read a LON-CAPA hosts.tab |