curtisb has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Everyone

I have a question! I just installed DBD:Sybase module into ActiveState Perl using PPM. When I run the code that I have copied out of "Programming the Perl DBI" (not a plug for the book), I get the following errors.

Can't locate DBI.pm in @INC (@INC contains: C:/Program Files/Perl/lib C:/Program Files/Perl/site/lib .) a t C:/Program Files/Perl/site/lib/DBD/Sybase.pm line 16.

BEGIN failed--compilation aborted at C:/Program Files/Perl/site/lib/DBD/Sybase.pm line 16.

Compilation failed in require at datasources.pl line 3.

BEGIN failed--compilation aborted at datasources.pl line 3.

Now is this because the book has bad code in it or have I missed copied something? I have doubled check the book and everything looks right.

What this code is suppost to do is check for which DBI drivers I have running on my machine.

Here is the code:

#!/usr/bin/perl -w use DBI::Sybase; use strict; my @drivers = DBI->available_drivers(); die "No drivers found!\n" unless @drivers foreach my $driver (@drivers) { print "Driver: $driver\n"; my @DataSources = DBI->$data_sources($driver); foreach my $DataSources(@DataSources) { print "\tData Source is $DataSources\n"; } print "\n"; } exit

So, my questions are:

1. Where is this @INC varible and how do I change it,if needed?

2. How can I get this code to work correctly?

3. Has anyone else ever used PPM from Active State?

Thanks.

Curtisb

Replies are listed 'Best First'.
Re: Question about DBI and PPM/DB Driver Verify Code
by MZSanford (Curate) on Nov 29, 2001 at 21:02 UTC
    I have used ppm. First , the problem :

    It appears DBI is not installed. You will want to run ppm install DBI to install it. DBD::Sybase requires this to run, and your program requires this to search for Data base drivers (DBD's). Also, use DBI::Sybase is incorrect. I believe in this code you only need use DBI.

    As for @INC, it is an array of directories checked for modules on your machine. This is compiled into perl and cannot (should not, not even with a good hex editor) be changed.

    Let us know how it goes.
    i had a memory leak once, and it ruined my favorite shirt.

      Thanks for the tip. I thought that DBI was installed already, guess not. Once I installed DBI I attempeted to run my code agin and I was given an error that says it cannot find libct.dll in my default path. I tried to find this dll on my hard drive with no luck. Can someone point me in the right direction.

      Thanks,
      Curtisb -- "Always misguided!"

        This error is because DBD::Sybase requires a local copy of the Sybase Open Client libraries. You can get them from sybase, i think ... once installed you should be good to go.
        i had a memory leak once, and it ruined my favorite shirt.
        I'll preface the following by saying that I use MySQL and Oracle, and not Sybase...

        I'm guessing that this dll is a part of Sybase which you need to have installed on your PC. Installing DBD::Sybase does not install actual Sybase drivers on your computer; you still need to have Sybase client software installed.

        If it is installed, you may need to set some environment variables so that DBD::Sybase can find it. Check the docs.

        buckaduck

        You need to have Sybase OpenClient installed. If your server is a Unix server then the Windows client libraries are included in the server distribution (on a separate CD, IIRC).

        Michael

Re: Question about DBI and PPM/DB Driver Verify Code
by curtisb (Monk) on Nov 30, 2001 at 00:31 UTC
    OK...going back to my original question. Maybe, I should have specified which OS I was on. I'm on a Win NT 4.0 system. I go the dll problem fixed, now I'm getting a bunch of other errors. Could someone point out the syntax mistake....I've been looking at this all day.

    Here are the error messages

    Driver: ADO

    Use of uninitialized value in method lookup at datasources.pl line 12.

    Use of uninitialized value in substitution (s///) at C:/Program Files/Perl/lib/AutoLoader.pm line 41.

    Can't locate auto/DBI/.al in @INC (@INC contains: C:/Program Files/Perl/lib C:/Program Files/Perl/site/li b .) at datasources.pl line 12

    Once again here is the code. A bit of a change.

    #!/usr/bin/perl -w use DBD::ODBC; my @drivers = DBI->available_drivers(); die "No drivers found!\n" unless @drivers; foreach $driver (@drivers) { print "Driver: $driver\n"; @DataSources = DBI->$data_sources( $driver ); foreach $data_sources( @DataSources ) { print "\tdata_source is $data_sources\n"; } print "\n"; } exit;
    Thanks in advance.
    Curtisb
      I think you mean:
      DBI->data_sources( $driver );
      rather than:
      DBI->$data_sources( $driver );
      Note the dollar sign. As usual, your typo would have been obvious if only you would use strict;

      buckaduck

        Thanks! That was it!

        Thanks agian,
        Curtisb