in reply to A Matter of Style in CGI
DBI things: 1. Check out the database handle attributes RaiseError, PrintError, and AutoCommit. For error checking(and catching) your DBI statements, especially in CGI scripts where you may not want to die(you might want to give a nice Error screen) when you have a bad problem, you can't beat RaiseError and "eval". 2. Get into the habit of using placeholders(?) - although they won't really buy you much here, you're bound to run into a situation where they will help with quoting issues and/or performance. Is use them *all* the time. 3. while (@_ = $sth->fetchrow_array()) { $emp_id = $_[0]; $emp_name = $_[1]; $dept = $_[2]; can be written to be more easily understandable this way: while (($emp_id, $emp_name, $dept) = $sth->fetchrow_array()) { no sense using array subscripts when it's not necessary. You might also have a look at fetchrow_hashref.
|
|---|