first commit
This commit is contained in:
26
perl/Examples/Chap2/def-conf-dir
Normal file
26
perl/Examples/Chap2/def-conf-dir
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
###
|
||||
### define_config_directive
|
||||
###
|
||||
|
||||
## Chapter 2 section 1.2
|
||||
|
||||
sub define_config_directive {
|
||||
my $rest = shift;
|
||||
$rest =~ s/^\s+//;
|
||||
my ($new_directive, $def_txt) = split /\s+/, $rest, 2;
|
||||
|
||||
if (exists $CONFIG_DIRECTIVE_TABLE{$new_directive}) {
|
||||
warn "$new_directive already defined; skipping.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
my $def = eval "sub { $def_txt }";
|
||||
if (not defined $def) {
|
||||
warn "Could not compile definition for `$new_directive': $@; skipping.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$CONFIG_DIRECTIVE_TABLE{$new_directive} = $def;
|
||||
}
|
||||
Reference in New Issue
Block a user