http://qs1969.pair.com?node_id=1123954


in reply to Data-driven Programming: fun with Perl, JSON, YAML, XML...

Personally I'd prefer working with a Domain Specific Language for configuration, far more flexible!

Each entry must be a sub in your my_config package, action is a sub action (&) {...} taking a code block with options.

It's not only easy to read for non programmers, but also easy to validate (just add prototypes and do argument checking within the subs)

package my_config; action { id 'svninfo'; desc 'svn working copy information'; cmdline 'svn info'; workdir ''; logfile 'minbld_svninfo.log'; tee 1; prompt 0; run 1; }; action { id 'svnup'; desc 'Run full svn update'; cmdline 'svn update'; workdir ''; logfile 'minbld_svnupdate.log'; tee 1; prompt 0; run 1; }; # ...

(update: features which are only boolean could be handled without arguments with useful defaults, i.e. run 1 is simply run and run 0 is skipped)

DRY could be achieved with preloaded constants, nested structures or special commands to set defaults like

default workdir => ''; # or default { workdir ''; } # or just a top-level setting workdir ''; action { # workdir can be missing now }

The fact that you can insert arbitrary perlcode is a mixed bag, it might add extra flexibility but also be a source of bugs with non-hackers. Deactivating builtins in CORE might be an option...

Dunno if there is already an appropriate module on CPAN (?), otherwise I'd volunteer producing one for the comming GPW.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!