[EMAIL PROTECTED] wrote:

> My conclusion is that the compiled drivers (DBD::MySQL and DBD::ODBC)
> actually require a compiled version of DBI to be loaded in order to
> function.


Yep.

> It is useless to try the pure perl DBI loading in the same file as the
> initial eval call.  Believe me, I tried.


The short code below should do what you want without either the extra 
file or an eval.  It makes use of the variable $DBI::PurePerl (different 
from the *environment* variable DBI_PUREPERL) to tell which version of 
DBI has been loaded.  It assumes that your own copy of DBI and some or 
all of the DBDs are in the directory '/modules'.

   # use DBI and DBDs in the standard dirs if available
   #   else use the ones in your own dir
   # use compiled DBI if it's available
   #   else use DBI::PurePerl
   # use AnyData,MySQL,ODBC if compiled DBI is in use
   #   else just use AnyData
   #
   BEGIN {push @INC,'/modules'; $ENV{DBI_PUREPERL}=1}
   use DBI;
   my $dbi_compiled = 1 unless $DBI::PurePerl;
   if ($dbi_compiled) {
       # do AnyData or MySQL or ODBC stuff
   }
   else {
       # do AnyData stuff
   }


> This essentially ensures that compiled DBI gets loaded and the DBI in
> the modules directory is never touched if DBI is compiled and active
> on the machine. 


But what I don't understand is why you would want to use the DBI in your 
private directory if there is already a compiled version working.  If 
you really want to do that, use unshift() instead of push() in the code 
above and it will force use of your version of DBI regardless of what 
else is or isn't on the machine.

-- 
Jeff

Reply via email to