htmanning has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl print "Content-type: text/html\n\n"; ######## REQUIRED FILES ########### require "cgi-lib.pl" || die "Error loading cgi-lib.pl"; require "db-common.sub" || die "Error loading db-common.sub"; $alertstable = "alerts"; $regtable = "registrations"; &Conn_to_DB; ###### Connect to bad emails database and get all the emails $SQL = "Select * from bademails ORDER BY ID DESC"; &Do_SQL; while ($pointer = $sth->fetchrow_hashref) { $bademail = $pointer->{'email'}; ###### Connect to alerts database and get the entries that match t +he bademail list $SQL2 = "Select * from $alertstable where email LIKE '%$bademail%' +"; &Do_SQL2; while ($pointer2 = $sth2->fetchrow_hashref) { $item = $pointer2->{'jobtype'}; $alerttype = $pointer2->{'alerttype'}; $emaillist = $pointer2->{'email'}; $ID = $pointer2->{'ID'}; @emails = split /~~~/,$emaillist; @goodemails = (); foreach $address (@emails) { #print "$ID, $address<Br>\n"; if ($address ne $bademail) { push @goodemails,$address; } } #end foreach $newlist=join('~~~',@goodemails); $SQL3 = "UPDATE $alertstable SET email='$newlist' WHERE jobtype='$i +tem' and alerttype='$alerttype'"; &Do_SQL3; print "updated $ID, $elist<Br>\n"; } #end while ($pointer2 = $sth2->fetchrow_hashref) { ###### Connect to reg database and set the alerts to nothing if it + matches a bademail $SQL3 = "UPDATE $regtable SET alerts='$alerts' WHERE email='$badem +ail'"; &Do_SQL3; print "Reset Reg. ID: $ID, $bademail<Br>\n"; } # end while $dbh->disconnect; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with script
by ww (Archbishop) on May 17, 2006 at 21:11 UTC | |
|
Re: Help with script
by GrandFather (Saint) on May 17, 2006 at 21:12 UTC | |
|
Re: Help with script
by TeraMarv (Beadle) on May 18, 2006 at 05:57 UTC |