cvsuser 03/07/10 06:58:28
Modified: App-BEGIN/lib/App BEGIN.pm
App-BEGIN/t app.conf main.t
Log:
anchored [regexp] at beginning and end of string
Revision Changes Path
1.3 +17 -3 p5ee/App-BEGIN/lib/App/BEGIN.pm
Index: BEGIN.pm
===================================================================
RCS file: /cvs/public/p5ee/App-BEGIN/lib/App/BEGIN.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- BEGIN.pm 20 Jun 2003 17:17:46 -0000 1.2
+++ BEGIN.pm 10 Jul 2003 13:58:28 -0000 1.3
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: BEGIN.pm,v 1.2 2003/06/20 17:17:46 spadkins Exp $
+## $Id: BEGIN.pm,v 1.3 2003/07/10 13:58:28 spadkins Exp $
#############################################################################
package App::BEGIN;
@@ -215,10 +215,13 @@
#################################################################
local(*App::FILE);
- my ($conf_file, $firstonly, $regexp);
+ my ($prog, $conf_file, $firstonly, $regexp, $excluding);
$firstonly = 1;
+ $prog = $0;
+ $prog =~ s!.*/!!;
while ($#conf > -1) {
$conf_file = shift(@conf);
+ $excluding = 0;
print STDERR "Looking for conf [$conf_file]\n" if ($conf->{debugconf});
if (open(App::FILE, "< $conf_file")) {
print STDERR "Found conf [$conf_file]\n" if ($conf->{debugconf});
@@ -230,8 +233,19 @@
# (also accept the "#![regexp] var = value" syntax)
if (s|^#[/\]] *||) {
$regexp = $1;
- next if ($0 !~ m!$regexp!); # keep only if "regexp" matches
the program name
+ next if ($prog !~ m!$regexp!); # keep only if "regexp" matches
the program name
}
+ elsif (s|^\[(.*)\] *||) {
+ $regexp = $1;
+ if ($_) {
+ next if ($regexp && $prog !~ m!^$regexp$!); # keep only if
"regexp" matches the program name
+ }
+ else {
+ $excluding = ($regexp && ($prog !~ m!^$regexp$!));
+ next;
+ }
+ }
+ next if ($excluding);
s/#.*$//; # delete comments
s/^ +//; # delete leading spaces
s/ +$//; # delete trailing spaces
1.3 +9 -0 p5ee/App-BEGIN/t/app.conf
Index: app.conf
===================================================================
RCS file: /cvs/public/p5ee/App-BEGIN/t/app.conf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- app.conf 20 Jun 2003 17:17:46 -0000 1.2
+++ app.conf 10 Jul 2003 13:58:28 -0000 1.3
@@ -1,8 +1,17 @@
var = value
#!/main/ var1 = pattern match
#![main] var2 = old pattern match
+[main.t] var3 = value3
dir = /usr/local
htdocs_dir = {:dir:}/htdocs
template_dir = {:dir=/usr/bad:}/template
cgibin_dir = {:dir2=/usr/local:}/cgi-bin
greeting = {:Hello:}
+[bozo]
+var4 = value4
+[]
+var5 = value5
+[bozo]
+var6 = value6
+[ma.*]
+var7 = value7
1.3 +5 -0 p5ee/App-BEGIN/t/main.t
Index: main.t
===================================================================
RCS file: /cvs/public/p5ee/App-BEGIN/t/main.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- main.t 20 Jun 2003 17:17:46 -0000 1.2
+++ main.t 10 Jul 2003 13:58:28 -0000 1.3
@@ -26,6 +26,11 @@
is($App::conf{cgibin_dir}, "/usr/local/cgi-bin", "variable substitution (default
used)");
is($App::conf{template_dir}, "/usr/local/template", "variable substitution (default
supplied but not used)");
is($App::conf{greeting}, "Hello", "variable substitution (var name used since var
not defined)");
+is($App::conf{var3}, "value3", "inline pattern match");
+is($App::conf{var4}, undef, "section excluded");
+is($App::conf{var5}, "value5", "section exclusion ended");
+is($App::conf{var6}, undef, "section excluded again");
+is($App::conf{var7}, "value7", "section included");
%App::conf = (
conf => "$dir/app.conf",