MCPM: The next MCPM meeting is TONIGHT 18 Nov

Andy Murren andy at murren.org
Tue Nov 18 14:21:04 CST 2003



Well, tonight is the meeting and I plan on attending.


: 
: Here is your reminder!
: 

Sorry gang, have not had a chance to fix this.  I turned it off
instead.  Here is the code is someone has a chance to look at it.  

-------------

#!/usr/local/bin/perl

use strict;
use Date::DayOfNthWeek qw(day_week);
use Mail::Sendmail;
use Getopt::Std;

our %opts;

getopts('d',\%opts);

print "$0 debugging on\n" if $opts{'d'};

my $d = 2; # set to the day of week I want -- SUNDAY=0
my $w = 2; # set to the week PRIOR to the meeting so I can send out the reminder

print "Day is $d and week is $w\n" if $opts{'d'};

my $from = 'andy at murren.org';
my $to   = 'morriscounty at pm.org';
#my $to   = 'andy at murren.org';
my $when = '';
my $subject = "The next MCPM meeting is ";
my $time ='7:30 pm';
my $where = 'The Dublin Pub in Morristown';


my $ok = day_week($d,$w);

if ($ok) {
        print "  The meeting is next week\n" if $opts{'d'};
        $when = "next Tuesday";
        &mailout;
}
else     {
    my $ww = $w+1;             # keeps me from changing the value of $w 
        if ($ww > 6) { $ww = 1; }  # fixes range input errors for wrapping to next week
        $ok = day_week($d,$ww);
        if ($ok) {
                print "  The meeting is tonight\n" if $opts{'d'};
                $when = "tonight";
                &mailout;
        }

        else {
                $d--;                   # see if this is the day before the meeting
                if ($d < 0) { $d = 6; } # fixes range input error for wrapping to previous week day
                $ok = day_week($d,$ww);
            print "  The meeting is tomorrow\n" if $opts{'d'};
            $when = "tomorrow" if $ok;
                &mailout;
        }
} 

sub mailout {

        my $message =<<"EOM";

Here is your reminder!

The next Morris County Perl Mongers Meeting is $when at $time.  
It will be held at $where.

Please email the list and let us know if you can make it.

Hope to see you there!

Andy

EOM

$subject .= $when;

    my %mail = ( To       => "$to",
                                 From     => "$from",
                                 Subject  => "$subject",
                                 Message  => "$message"
                                 );

        sendmail(%mail) or die $Mail::Sendmail::error;

        open (LOG, ">> $ENV{HOME}/mcpm.log") or die "could not open log: $!";

        print LOG "OK. Log says:\n", $Mail::Sendmail::log;
        print LOG "\n\n";

}



-------------

Andy

--
Andy Murren
andy (at) murren (dot) org



More information about the morriscounty-pm mailing list