[Mimedefang] mysql mimedefang

alan premselaar alien at 12inch.com
Thu Jul 3 11:01:01 EDT 2003

On 7/3/03 11:02 PM, "B. Tolka" <btolka at hsc.wvu.edu> wrote:


> while( $sth->fetch() )
> {
> open(FD, ">> /etc/mail/spam_disabled_users.txt");
> print FD "$username\n";
> }
> close(FD);
> $sth->finish;
> $dbh->disconnect;

The thing that jumps out at me is the fact that you've got your open
statement inside your while {} loop, yet your close is outside of the loop.

I personally try to avoid open/close statements in loops if possible.
also, i personally like to call die() if the open fails... (or some other
means of reporting that the open failed as appropriate)

you may want to try rewriting the above as:

open(FD, ">> /etc/mail/spam_disabled_users.txt") || die "unable to open
spam_disabled_users.txt file";

while ( $sth->fetch() ) {
    print FD "$username\n";

... etc.

it's possible that the open failed for some reason, yet you were trying to
print to the file descriptor anyways and causing that error.

hope this helps.  anyone else can feel free to correct me if i'm smoking


More information about the MIMEDefang mailing list