use DBI; my $dbh = DBI->connect( $main::location, $main::user, $main::ba_pass, {RaiseError=>1,AutoCommit=>1} ) or die "Couldn't connect to database: " . $DBI::errstr; # # indent one level for the eval block # eval { my $sth= $dbh->prepare("SELECT id FROM sessions"); my $id; $sth->execute(); $sth->bind_columns(undef, \$id); require CGI::Session; import CGI::Session; # # indent a second level for the while block # while ($sth->fetch()) { my $session = CGI::Session->load( "driver:MySQL", $id, {Handle=>$dbh} ); next if $session->is_empty; # # indent a third level for the if block # if (($session->ctime + $session->etime) <= time()) { $session->delete(); } } }; if ($@) { print $@; $dbh->disconnect(); }