Hi all,
The script below is supposed to get a certain number of email addresses
from a database, print them (at a later stage "print" is replaced by a
command to send the mails) and sleep for a while before starting the
process again until the loop ends.
I works, but has two flaws.
a) the record with the id 3 is gotten twice
b) and all the records > 15 are not printed/sent at all.
is there a better way to read from the database, send, sleep and start again?
Thanx
Marcus
#!/usr/bin/perl
use DBI;
$dbh = DBI->connect("DBI:mysql:host:localhost;database=juvis", "xyz",
"xyz", {PrintError => 0, RaiseError => 1});
$result = 17;
$i = 0;
for($i = 0; $i <= $result; $i += $a){
$a = $i +3;
$sth = $dbh->prepare(qq{SELECT email FROM name_email WHERE id BETWEEN
$i and $a});
$sth->execute();
while($mail=$sth->fetchrow_array()){
print "$mail\n";
}
sleep 10;
}
Marcus Willemsen
Online Redaktion
Juve Verlag
Agrippastr. 10
50676 Köln
tel: ++49(0)221 91 38 80 10
fax: ++49(0)221 91 38 80 18
www.juve.de
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]