in reply to DBI detector?

first, you have to get rid of the use DBI; inside the if() statement -- that is being run at compile time (see use). For (attempting) loading at runtime, see require. Also I think your $@ logic is backwards (see eval)... Try something like this:
eval "require DBI"; my $dbi_ok = $@ ? 0 : 1; if( $dbi_ok ){ # do DBI stuff here }else{ print "NO DBI\n"; }

Replies are listed 'Best First'.
Re^2: DBI detector?
by jcpunk (Friar) on Apr 03, 2006 at 20:56 UTC
    Bingo! I thank thee

    jcpunk
    all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)
Re^2: DBI detector?
by ikegami (Patriarch) on Apr 03, 2006 at 21:19 UTC
    Why did you switch from eval "use DBI" to eval "require DBI"? Both occur at run-time here (since the eval is executed at run-time here), but require doesn't import the symbols that use would import.
      mostly cause require docs use the eval "require DBI" form as an example, and so i was pretty confident that would work w/o trying it, and the critical piece for OP was to remove the load-time 'use' call .. i also vauguely remember having problems once doing a eval "use Foo" once but really can't remember what (possibly {probably??} totally unrelated .. was a load order issue maybe??) .. so, in summary, no real good reason :)
        Maybe you had problems with eval { use Foo; }. That won't work because the block of eval BLOCK is compiled when the eval is *compiled*. eval "use Foo;" is different because the expression in eval EXPR is compiled when the eval is *executed*.