24 lines
530 B
Plaintext
24 lines
530 B
Plaintext
|
|
|
|
###
|
|
### read_config_default
|
|
###
|
|
|
|
## Chapter 2 section 1.4
|
|
|
|
sub read_config {
|
|
my ($filename, $actions, $userparam) = @_;
|
|
open my($CF), $filename or return; # Failure
|
|
while (<$CF>) {
|
|
chomp;
|
|
my ($directive, $rest) = split /\s+/, $_, 2;
|
|
my $action = $actions->{$directive} || $actions->{_DEFAULT_};
|
|
if ($action) {
|
|
$action->($directive, $rest, $actions, $userparam);
|
|
} else {
|
|
die "Unrecognized directive $directive on line $. of $filename; aborting";
|
|
}
|
|
}
|
|
return 1; # Success
|
|
}
|