Subject: | Allow multiple (array) args on one line of config file. |
I wanted to specify in a config file multiple values
for an ARGCOUNT_LIST parameter, but instead
of having to specify them on multiple lines like so:
parameter=value1
parameter=value2
etc.
I wanted to be able to specify them on one line like so:
parameter=value1, value2
My thinking is that is is best implemented as a patch to the
main source (considering what I had to do) rather than
a subclass of AppConfig...
I implemented this (AFAICT) in a completely backwards compatible
way by introducing a 'SPLIT' parameter which is similar to
the VALIDATE parameter in that it takes a regex or a code ref,
but is used to split up the value(s) on specified parameters (
and if a regex, its the regex used in a split function).
E.g. for the above, you might have...SPLIT=>"[,\s]+"
If its a code ref, you could use it to split up, e.g. quoted-CSV
type parameters (and could be handy in that it can pre-process
any parameters):
csv_param="This value", "That value", "etc"
(diff -ruN patchfiles attached)
Let me know what you think,
--- ../AppConfig-1.52/AppConfig.pm Wed Oct 24 14:36:48 2001
+++ AppConfig.pm Tue Nov 27 16:14:07 2001
@@ -464,8 +464,8 @@
=item GLOBAL
Reference to a hash array of global values used by default when defining
-variables. Valid global values are DEFAULT, ARGCOUNT, EXPAND, VALIDATE
-and ACTION.
+variables. Valid global values are DEFAULT, ARGCOUNT, EXPAND, SPLIT,
+VALIDATE, and ACTION.
=item PEDANTIC
@@ -588,6 +588,11 @@
other AppConfig variables, EXPAND_UID - expand C<~uid> as user's home
directory, EXPAND_ENV - expand C<${var}> as environment variable,
EXPAND_ALL - do all expansions. May be logically or'd.
+
+=item SPLIT
+
+Regex with which the intended variable value is split or code reference
+which a list of values.
=item VALIDATE