You could do something like:

unless (time % 5) { (forward mail) }

The percent is the modulus operator, which gives the integer remainder of the divisor. 6 % 5 is 1. 12 % 5 is 2. 10 % 5 is 0. As time() is delivered in seconds since the epoch, you can see if it is divisible by 5 (every 5 seconds). If it is, you do something with it.

Alternately, you could put the whole thing in a loop:

while (1) { sleep 5; (forward mail) }

But you'll probably want some kind of monitoring service to check to make sure your daemon is still alive and running.

Of course, if your purpose is simply to forward all mail from an inbox to a particular address, you don't need to use perl for that. More than likely, you could just use your MTA software.

Sendmail uses .forward files. You can use procmail rules to forward mail. Qmail uses .qmail files. (I'm not familiar with Postfix, but I'm sure there's a way to do it there, too.) check with your service provider.


In reply to Re: Mail::Audit and time sensitivity by saintbrie
in thread Mail::Audit and time sensitivity by Anonymous Monk

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.