#!/usr/bin/perl -wT ############################################################ ## Written and copyright 2002 by ## Jacqueline D. Hamilton (kira@cgi101.com) ## ## This code is excerpted from "CGI Programming 201" ## (http://www.cgi101.com/advanced) ## ## You may use this code on your own website, however ## you may not publish or sell any copy or derivative work ## without permission of the author. ############################################################# use strict; use lib '.'; use MyBoard qw($dbh delete); my($sth, $rv, $asth, @ary, $f, $g); $sth = $dbh->prepare("select * from forums where expiretime > 0"); $rv = $sth->execute; while ($f = $sth->fetchrow_hashref){ $asth = $dbh->prepare("select id from messages where forum=? and date < date_sub(current_time(),INTERVAL ? DAY)"); $rv = $asth->execute($f->{'id'},$f->{'expiretime'}); @ary = $asth->fetchrow_array; foreach my $g (@ary) { &delete($g); print qq(Message $g expired.\n); } }