Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Email days until election

by zeno (Friar)
on Feb 09, 2007 at 21:06 UTC ( #599284=CUFP: print w/replies, xml ) Need Help??

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(''); $smtp->mail(''); $smtp->recipient(''); my $msg = ""; $msg .= << 'HEADER'; Priority: Non-Urgent Importance: low sensitivity: Personal From: "Election Day" <> To: <> 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;

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://599284]
Approved by kyle
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2023-10-04 20:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found