On Mon, 1 May 2000, Matt Sergeant wrote:

> It would be nice, in my opinion, to have some way of doing:
> 
> PerlAddVar Fred "Value 1"
> PerlAddVar Fred "Value 2"
> 
> And then in your script:
> 
> my @values = $r->dir_config('Fred');
> 
> which gets ("Value 1","Value 2") in @values.
> 
> Any thoughts on this? (I'm not set on the name PerlAddVar, if that's
> anyone's concern - but what about the idea of it?)

you could implement that with a directive handler, that uses
$r->dir_config->add at request time.

though, it would be simple to add to mod_perl.  patch below compiles, but
i haven't tested.

then your script can have:

my @values = $r->dir_config->get('Fred');

Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/mod_perl.c,v
retrieving revision 1.116
diff -u -r1.116 mod_perl.c
--- src/modules/perl/mod_perl.c 2000/04/13 06:07:33     1.116
+++ src/modules/perl/mod_perl.c 2000/05/04 05:56:48
@@ -126,6 +126,9 @@
     { "PerlSetVar", (crft) perl_cmd_var,
       NULL,
       OR_ALL, TAKE2, "Perl config var and value" },
+    { "PerlAddVar", (crft) perl_cmd_var,
+      (void*)1,
+      OR_ALL, TAKE2, "Perl config var and value" },
     { "PerlSetEnv", (crft) perl_cmd_setenv,
       NULL,
       OR_ALL, TAKE2, "Perl %ENV key and value" },
Index: src/modules/perl/perl_config.c
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.95
diff -u -r1.95 perl_config.c
--- src/modules/perl/perl_config.c      2000/05/04 04:52:34     1.95
+++ src/modules/perl/perl_config.c      2000/05/04 05:56:51
@@ -729,11 +729,21 @@
     MP_TRACE_d(fprintf(stderr, "perl_cmd_var: '%s' = '%s'\n", key, val));
     if (cmd->path) {
         perl_dir_config *rec = (perl_dir_config *) config;
-        table_set(rec->vars, key, val);
+        if (cmd->info) {
+            table_add(rec->vars, key, val);
+        }
+        else {
+            table_set(rec->vars, key, val);
+        }
     }
     else {
         dPSRV(cmd->server);
-        table_set(cls->vars, key, val);
+        if (cmd->info) {
+            table_add(cls->vars, key, val);
+        }
+        else {
+            table_set(cls->vars, key, val);
+        }
     }
     return NULL;
 }

Reply via email to