in reply to Re: CGI::Session disconnect invalidates 1 active statement handle
in thread CGI::Session disconnect invalidates 1 active statement handle

Hi perleager. I didn't mean to sound too harsh, and it's not like indenting is the most important thing and tastes vary. But in a chunk of code like you have, I find it most useful to indent mostly based on blocks -- start the indent with the opening "{" of the block and end the indent with the closing "}". This lets you see at a glance which block each line is part of and also to easily check to make sure you didn't omit a curly brace. I sometimes also indent arguments to functions using the opening and closing parentheses to see where to indent. Here's how I would indent your code (again, tastes vary, this is just my way):
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(); }

update:renamed it so I could find it :-)