Johnson, Shaunn [[EMAIL PROTECTED]] quoth:
*>Hi again:
*>
*>This is my first attempt at trying to pull info from a
*>database ... but this is my goal:

Examples are likely the best and fastest way to get a handle on something
like this. I use the following hack to select cpan mirrors out of the db
and mail out a notice to the mirrors that match the criteria. It's ugly,
but it works :)

I also highly recommend the DBI book http://dbi.symbolstone.org/ and all
the examples from the DBI book are on-line
http://examples.oreilly.com/perldbi/

e.

#! /usr/local/bin/perl -w

use DBI;
use strict;

    my $dbh = DBI->connect( "your connect info here" );
    my $sth = $dbh->prepare( "
                SELECT name,contact,retiredate,status
                FROM yourtable
                WHERE retiredate='' AND status='good'
             " );
    $sth->execute();

    while ( my ($name,$contact,$retiredate,$status) = $sth->fetchrow_array ) {

open(SENDMAIL, "|/usr/lib/sendmail -t -f your\@email.address")  ||
  die("can't fork SENDMAIL: $!");

print SENDMAIL<<EOT;
To: $contact
Subject: Grod send mail to you

Dear $name,

blah blah blah
 
EOT
close (SENDMAIL);
}

$dbh->disconnect;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to