[oak perl] Perl scripts.....

M. Lewis cajun at cajuninc.com
Sun Dec 1 00:17:26 CST 2002


I told George of this script a couple of days ago. He thought it was a
good practical use for Perl.

My G/F is Jewish. She has a hard time remembering to light her candles
on Fridays. I had an equally hard time remembering to remind her. Enter
perl....

Again, I setup a cron job like so:

30 16 * * 5 /home/cajun/HOME/perl/candles/candles.pl

Then a short Perl script to do the work. It sends a text message to her
cell phone at 430pm on Fridays. It also sends the same reminder to me
just so I know it worked. (I munged the phone numbers to protect the
innocent):

#!/usr/bin/perl -w
use strict;

use MIME::Lite;

my @recipients = qw( 4155551212 at mobile.mycingular.com
                     5105551212 at mobile.mycingular.com
                   );

my $wait_time = 900;  # 900 seconds is 15 minutes
my $debug = 0;

my @messages = (
       "It's Friday. It's candle day. Don't forget...",
       "It's going to be dark soon. Remember it is candle day...",
       "Last warning. Candle day..."
);

my $total = @messages;
my $index = 1;

foreach (@messages){
   &send_message($_);
   if ($debug) {print "Index is: $index\n"};
   if ($index < $total){
      if ($debug) {print "Sleeping $wait_time seconds\n"};
      sleep $wait_time;
      $index++;
   }
}

sub send_message{
    if ($debug) {print "Sending message: $_\n"};
    my $msg = MIME::Lite->new(
                From    =>'cajun at cajuninc.com',
                BCc     =>"@recipients",
                Subject =>"",
                Type    =>'TEXT',
                Data    =>$_
                );
$msg->send;
}

-- 
  
  IBM: Inevitably Bad Marketing
 10:10pm  up 8 days, 21:49,  4 users,  load average: 1.12, 1.15, 1.15
  
  Linux Registered User #241685  http://counter.li.org




More information about the Oakland mailing list