Many thanks (and a ++ tomorrow) to zby, crouchingpenguin, dakkar, robartes, Jenda and hiseldl for their insightful replies.

The solution I have come up with is to use the tie functionality within Config::IniFiles and a slightly modified version of robartes regular expression approach. The while loop handles nested tokens (unlikely as they are in my case).

The following is a code snippet of the approach I intend to use. Comments welcome.

#perl -w use strict; use warnings; use Config::IniFiles; my ($appname, $cmdline, $priority, $szProcess); my %config; tie %config, 'Config::IniFiles', (-file => 'service.ini', -nocase => 1 +); my @processesToStart = map { $config{'service'}{$_} } grep { /^start[0-9]+/ } keys %{$config{'service'}}; foreach $szProcess (@processesToStart) { #Break process down into it's parts ($appname, $cmdline, $priority) = split /;/, $szProcess; #Process cmdline while ($cmdline =~ s/%([^%]+)-([^%]+)%/$config{lc $1}{lc $2}/eg) {} #Log and run it already print $cmdline, "\n"; } __END__ Text of service.ini: [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 Output: browser schedule "localhost:e:\users\dbush\schedule.gdb"

The other modules mentioned look interesting (esp. Win32::Daemon::Simple) but I'm afraid I'm up against a bit of a deadline. I also didn't mention that the configuration file must be a standard ini as I share it with some C programs.

Thanks again,
Dom.

Update: Corrected output typo.


In reply to Re: Substituting tokens into configuration values by dbush
in thread Substituting tokens into configuration values by dbush

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.