There are many different approaches, with varying complexity.

One is to just change the sleep interval to 0.1 or 0.05 seconds (use Time::HiRes for that), and only perform light weight checks in your "event loop" (for example check timestamps, and if a timestamp changes you can read a file again).

A slight variation is to install handlers for SIGUSER1 or other user specific signals, and sens a signal from to the long running application whenever you change something. See perlipc for more inspiration.

Another approach is to use an event framework like POE that does all the hard stuff for you: it can monitor files, set timeouts and all that stuff.


In reply to Re: Change in config from outside ==> immediate reflection? by moritz
in thread Change in config from outside ==> immediate reflection? by Gilles0181

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.