Here's how I do it in
DBI::SQL::Nano -
BEGIN {
if ($ENV{DBI_SQL_NANO} || !eval { require "SQL/Statement.pm" }) {
@DBI::SQL::Nano::Statement::ISA = qw(DBI::SQL::Nano::Statement
+_);
@DBI::SQL::Nano::Table::ISA = qw(DBI::SQL::Nano::Table_);
}
else {
@DBI::SQL::Nano::Statement::ISA = qw( SQL::Statement );
@DBI::SQL::Nano::Table::ISA = qw( SQL::Eval::Table);
}
}
Doing it in the BEGIN block means the if statement will only be evaluated once per require. Using Environment Variables gives the flexibility of choosing alternate modules once per server, once per user, once per script, or once per script invocation. Doing the eval on the require allows for a default mode if one of the alternatives is not available in a given context.