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 !? :")
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.