first commit
This commit is contained in:
21
perl/Examples/Chap2/rdconfig-uparam
Normal file
21
perl/Examples/Chap2/rdconfig-uparam
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
###
|
||||
### read_config_userparam
|
||||
###
|
||||
|
||||
## Chapter 2 section 1.3
|
||||
|
||||
sub read_config {
|
||||
my ($filename, $actions, $user_param) = @_;
|
||||
open my($CF), $filename or return; # Failure
|
||||
while (<$CF>) {
|
||||
my ($directive, $rest) = split /\s+/, $_, 2;
|
||||
if (exists $actions->{$directive}) {
|
||||
$actions->{$directive}->($rest, $userparam, $actions);
|
||||
} else {
|
||||
die "Unrecognized directive $directive on line $. of $filename; aborting";
|
||||
}
|
||||
}
|
||||
return 1; # Success
|
||||
}
|
||||
Reference in New Issue
Block a user