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