This code sends me an email with the number of days until a significant event; in this case, the 2008 election. It could easily be adapted to send the number of days since an event (a sobriety date, for example, or the days since you started programming in Perl).

I run a cron job to send this email to myself every day.

use strict; use Net::SMTP; use Date::Format; use Date::Calc qw(Delta_Days Add_Delta_Days); my $smtp=Net::SMTP->new('mail.sample.com'); $smtp->mail('zeno@sample.com'); $smtp->recipient('zeno@sample.com'); my $msg = ""; $msg .= << 'HEADER'; Priority: Non-Urgent Importance: low sensitivity: Personal From: "Election Day" <zeno@sample.com> To: <zeno@sample.com> HEADER # Set Expiry Date 1 day in the future my $expiry_date = time2str("%a, %d %b %T %Y %z", time+86400); $msg .= "Expiry-Date: " . $expiry_date ."\n"; my ($now_yr, $now_mon, $now_day) = (localtime)[5, 4, 3]; $now_mon += 1; $now_yr += 1900; my $days_until = Delta_Days($now_yr, $now_mon, $now_day, 2008, 11, 04) +; $msg .= "subject: " . $days_until . " days til election\n\n"; $msg .= $days_until . " days til election\n\n"; $smtp->data($msg); $smtp->quit;

In reply to Email days until election by zeno

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.