in reply to Clean Code - What a mess...
Second, using prepare_cached WITHOUT placeholders (with variable arguments) is a very bad idea. You WILL use alot of memory if there is alot of unique input. If your insert statement will have a limited number of table names, then use prepare_cached, but use it WITH placeholders (search this site and see the DBI docs). If you're going to have an unlimited number of table names per script, then use prepare instead of prepare_cached, but DO still use placeholders (with most databases, the table name can not be a placeholder argument, it might be different with mysql, though not portable).
Last, you're not checking the status of any of your DBI calls (except the connect). You might want to look into RaiseError (see the DBI docs), and wrap the whole thing in an eval{}, then check $@, or check the status of each DBI call (prepare, execute, etc.).
|
|---|