hi,
I will be generating a bunch of different config files in my case dhcpd.conf, tcng.conf (traffic control), docsis, probably dns zones, address user base and so on...
I can do it one by one but this soon will get complicated, on the other hand i'm pressed from the time (so can't think and implement do-it-all solution, but mostly something that can be extended easly).. I will explain my current thoughts, and hope u will give me better ones :"). Or probably will find my ideas good enought :")
All files at the moment will be generated from hashes or pipe-delimed text files. I have to leave some "door-open" for upgading this to SQL DB..
So on the question..
The main problem with the generation comes 'cause the generation-algorithm may benefit if not doing generation in linear fashion i.e. from top to down (begin to end of file).
Then comes the next decision I have to split the file on blocks and fire events on every block i.e. via callbacks ? The next consequence from this is that I have to build config-file skeleton (which I want to miss very much :"), probably not possible)
To get better picture here is one simple skeleton :
#include header.dhcp
group {
#block subnet1 subnet1Sub
}
#block hosts-declaration hostdeclSub
#include footer.dhcp
Then in the perl program pseudo code :
read&parse(skeleton);
run();
sub hostdeclSub {
$res .= "host $hosts{$_}{name} { hardware-address $hosts{$_}{mac
+} }\n" for keys %hosts
return $res
}
This is very simplified example.. there should be pre,post block callbacks, some identetion system should be included.. Probably "block" hierarcy too (tree-like may be)..
Plus the ability of one block to call-inqury another block generation with ability to stop infinte recursion, etc,etc...
Some status info should be available in callbacks (such as in which block i'm?, what has been generated in the prev block?, does the block X have string 'blah'?...)
switch on-off generation of some blocks in perl and/or in skeleton..
this start to seem like macro system with callbacks in Perl :"))
Your ideas... what comes to your mind when u want to generate config files..
hmm........ can "Inline"-module help in some way !? :")