in reply to DBI detector?

Except for the extra/missing paren, some redundancy, your code looks fine to me. What's your exact error message? Maybe a DBI *driver* is missing, as opposed to DBI itself.

my $use_dbi = eval ' use DBI; use DBD::mysql; 1 # or undef if the above fails. '; if ($use_dbi) { ... } else { print "NO DBI\n"; } ... do other stuff ...

Replies are listed 'Best First'.
Re^2: DBI detector?
by jcpunk (Friar) on Apr 03, 2006 at 20:18 UTC
    Error wise I get
    Can't locate DBI.pm in @INC (@INC contains: .....)  at DBIDetector.pl line 14

    jcpunk
    all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)
      Hum, there goes my theory. Could you show us your script, especially what's at and around line 14?
        Sure... here it is
        #!/usr/bin/perl use strict; my $use_dbi = 1; eval("use DBI;"); $use_dbi = 0 if (not($@)); print `uname -n`; print `prtconf |grep Mem` if (`uname` eq 'SunOS'); print `cat /proc/meminfo` if (`uname` eq 'Linux'); if ($use_dbi) { use DBI; print "Hurray!!\n"; } else { print "NO DBI\n"; }
        ... for what it is worth...

        Thanks for the interest.


        jcpunk
        all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)