http://qs321.pair.com?node_id=244581

dbush has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I appear to be suffering from brain fade today and so I'm having a bit of difficulty starting what I feel should be a simple problem. I wonder if anyone with a working brain can help?

Background: I am trying to write a Win32 service using PerlSvc from ActiveState to achieve something like this SOAP in an NT Service but as I can't predict what I will be running with it later, I wish to have the service driven by a configuration file.

Problem: I wish to enhance my configuration file with "tokens" that refer to other sections of the ini file.

This service has only the following purposes in life:

  1. Read an ini file (Config::IniFile).
  2. Start up a number of processes defined in it (Win32::Process)
  3. Check that the process don't go away over time (Win32::Process)
  4. When the time comes (i.e. the service is cancelled) shut the processes down again (Win32::Process).

The ini looks like this:

[GENERAL] scheduledb=e:\users\dbush\schedule.db [SERVICE] debug=1 interval=5 start1=browser.exe;browser;NORMAL_PRIORITY_CLASS start2=schedule.exe;schedule "localhost:%general-scheduledb%";NORMAL_P +RIORITY_CLASS

The format of the start lines is appname;cmdline;priority.

I have the basics of this, reading the .ini, starting the processes, monitoring then and then shutting them, working well and am happy about this. The problem comes that I wish to extend the command line section to include "tokens" e.g. %general-schedule% that can be parsed to include other configuration items e.g. e:\users\dbush\schedule.db.

After briefly contemplating using one of the templating modules (node Best templating system? and various others) I'm wondering if this is a bit of a sledgehammer approach? Would a better approach be to extract the tokens, retrieve the values and then substitute them back in? I had a Super Search but with little success.

Any help appreciated.

Regards,
Dom.