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

I've finally decided to learn how to use the DBI module =) Needed some help though -- I have never installed a module myself =P I'm running Mandrake Linux and I found the DBI.pm source from CPAN -- just needed to know where to place it and how to set it up to be called.

Replies are listed 'Best First'.
Re: Installing DBI module
by data64 (Chaplain) on Jan 18, 2003 at 19:37 UTC
Re: Installing DBI module
by abatkin (Sexton) on Jan 18, 2003 at 23:04 UTC
    Since you are running Mandrake, in addition to using CPAN/downloading the source, you can also install a premade RPM package that will take care of everything. Head off to your local Mandrake mirror (or Mandrake CD set) and download the relevant DBI module...In the case of Mandrake 9.0 it would be perl-DBI-1.30-2mdk.i586.rpm. Then just install it:
    rpm -i perl-DBI-1.30-2mdk.i586.rpm
    In addition to the DBI RPM (or perl package) you will probably need a specific module for whatever database type you are connecting to. Two of the more popular ones seem to be mysql and postgresql...In the case of mysql, you would want DBD::mysql (rpm file perl-Mysql-1.22_19-5mdk.i586.rpm) and in the case of Postgres, DBD::Pg (rpm file perl-DBD-Pg-1.01-4mdk.i586.rpm, which won't be in the base install or first 3 CDs, its actually in the contribs section so check out the mirrors).
Re: Installing DBI module
by bart (Canon) on Jan 19, 2003 at 10:44 UTC
    DBI is a module that relies on XS, meaning the bulk of it is written in C, the Perl part is mostly only a connection layer between Perl and the module. As a consequence, "placing it in the right place" can't work: the module must be built first, which involves a C compiler. You can use a module like CPAN to (optionally) download and install a module, or you can download it by hand, extract the .tar.gz file, and at the command prompt, cd to the main directory that got extracted, and type the following commands, one at a time:
    perl Makefile.PL make make test make install
    Do not proceed to the next command if the output of the last command doesn't look right. For example, do not type "make install" if "make test" complains.

    Why am I even typing that here? The DBI docs even mention this, at the very top, under "quick start"

    It is possible to "just place the files at the appropriate place" if you do have prebuilt binary files for your platform. For example, that's what Activestate provides for this kind of modules for Windows (all versions), for example: the XS parts come built as DLL files.

      I found that install stuff inside the doc's aswell -- just ran into a different stumbling block (suprise suprise lol). I'm over at Mandrake Expert right now trying to resolve that (it's dealing with the compilers). I'll post back here if I have anymore problems with this on the module side -- thanks.
        Ah, OK. It looked to me as if you hadn't even bothered to check out how one is supposed to install a module. With the info in the README for the module you're trying to install, that doesn't look good at all.

        Just some extra info on what that sequence of commands does: perl uses a utility called make to build and install the modules. For this it depends on a list of instructions in a file called "Makefile", in the current directory. On the plus side, make checks out dependencies: if a file "b" depends on a file "a", and the modification date of "a" is more recent than that of "b", then make will rebuild "b". On the minus side, make has a user-unfriendly syntax, for example, it makes a huge distinction between tabs and spaces, while both are invisible characters.

        So Perl uses a somewhat more user-friendly, and more platform independent, way, and a script "Makefile.PL", which comes with the module, is used to construct the "Makefile". That's what "perl Makefile.PL" does.

        Next, "make" builds the files. That may involve building loadable libraries using a C compiler. After this step, the final files all do exist.

        The next step, "make test", manipulates @INC so the test scripts, which reside in the "t" subdirectory, and which all carry the file extension ".t", can be run. These test scripts test all sorts of things that are essential for minimal working of the module, and stuff that is known to have gotten broken in the past.

        And finally, if all went well thus far, "make install" will copy the built files in their appropriate final place of the modules file tree.