#!/usr/local/bin/perl require "db-common.sub" || die "Error loading db-common.sub"; $rootpath = "/usr/www/users/me/reg/"; $regtype = "ch"; $yeartodelete = "2002"; if ($regtype eq "ch") { $jobstable = "joblistings"; } else { $jobstable = "jobswanted"; } &Conn_to_DB; $SQL = "SELECT * FROM registrations where regtype='$regtype' and dateadded LIKE '%$yeartodelete%' order by ID asc"; &Do_SQL; $recordcount = $sth->rows; print "there are a total of $recordcount registration records from $yeartodelete
\n"; while ($pointer=$sth->fetchrow_hashref) { $username=$pointer->{'username'}; $userdirectory = $rootpath . $username; ###### Connect to jobs database and get the entries that match the username $SQL2 = "SELECT * FROM $jobstable where username='$username' and active!='yes'"; &Do_SQL2; $recordcount2 = $sth2->rows; print "There are $recordcount2 records in the $jobstable database
\n"; print "$username directory exists\n"; while ($pointer2 = $sth2->fetchrow_hashref) { $username2=$pointer2->{'username'}; $usernamelist=$pointer2->{'username'}; @users = $usernamelist; foreach $username2 (@users) { print "$username directory exists and will be deleted\n"; #system ("rm -r $userdirectory"); #print "$userdirectory directory deleted\n"; } #end foreach } #end while ($pointer2 = $sth2->fetchrow_hashref) { } #end while ($pointer=$sth->fetchrow_hashref) { print "$recordcount2 directories deleted
\n"; print "there are a total of $recordcount registration records from $yeartodelete
\n"; $dbh->disconnect; exit;