[Za-pm] Re: Za-pm digest, Vol 1 #21 - perl modules

Nick Cleaton nick at cleaton.net
Tue Jun 3 08:05:57 CDT 2003


On Tue, Jun 03, 2003 at 02:06:05PM +0200, Dr Giancarlo Contrafatto wrote:
> > 
> >   locate '*/Foo.pm'
> 
> Yep, done that and downloaded the offending modules. This fixed a few
> errors but not all. By the look of the first compiler message below, I
> must now go and hunt for more modules.
> 
> In this first example, I'm just testing the Tk.pm with the simple "Hello
> World" script that comes with the pod. The code, which I forgot to send
> to my office machine, starts off as it should (I think):
> 
> #! /usr/perl -w
> 
> use Tk;
> use strict;
> ... and then the code to write "Hello World", which is not crucial to
> have right now.
> 
> The message is as follows:
> 
> Can't locate loadable object for module Event in @INC (@INC contains:
[SNIP]
> 
> Now, Events.pm is one of the modules I was missing (the preceding error
> message pointed to it), so I downloaded it and "just placed" it in the
> path. In restrospect, this may have been a dumb way of doing it because,
> by the look of it, there are plenty dependencies to be taken care of.
> The way I see it (check my reasoning here), the whole sequence fails
> straight away (line 2 of the hello script) where Tk is used. It fails
> because Tk depends on Events.pm which, in turn, depends on
> all_watchers.pm but also needs some unspecified "loadable object" which
> I haven't been able to identify by checking around line 23 of Events.pm.
> So, maybe I should have "made" Tk when I downloaded it but, it came
> without makefile and the pod didn't mention anything about
> installations.

Yes, that's it exactly, you need to get the module source and build it
rather than downloading individual .pm files.

The 'loadable object' refers to the part of the Tk module that's written
in C rather than Perl.  That needs to be compiled on your system to make
a loadable object which the Perl interpreter can load up when loads Tk.pm

There are several different ways to get Tk.pm properly installed:

via your package manager
========================

I don't know Redhat that well, but I expect there's a graphical package
manager that lets you fetch and install RPMs to get extra software.
Since you're using the perl that came with Redhat, you may find that you
have the option of installing the Tk module as an RPM.

via CPAN
========

CPAN (the Comprehensive Perl Archive Network, http://www.cpan.org/) is
an online repository of perl modules.  Perl comes with a module
(CPAN.pm) which you can use to fetch, build and install stuff from CPAN.

To get Tk from CPAN, you might do something like this at the shell
prompt:

  perl -MCPAN -eshell

CPAN.pm will ask you some questions if this is the first time you've
used it, and then give you a prompt like:

  cpan> 

At this prompt, enter the command:

  install Tk

... and it will download the Tk module from a CPAN mirror and build and
install it for you.

from source
===========

If you don't want to use CPAN.pm, you can download the latest version of
the Tk module source and build it yourself.  The source is available for
download at:

http://ftp.rucus.ru.ac.za/pub/perl/CPAN/modules/by-module/Tk/Tk800.023.tar.gz

After fetching that file:

  gzip -dc Tk800.023.tar.gz
  cd Tk800.023
  perl Makefile.PL
  make
  make test
  make install

... which is what pretty much what CPAN.pm does for you.

With this approach you may find that the installation fails because Tk
needs some other module to be installed first, which you then need to
fetch and install before trying the Tk installation again.

One of the nicest things about CPAN.pm is that it will sort out these
dependencies by itself, fetching and installing any other modules that
Tk needs before trying to install Tk.

--
Nick



More information about the Za-pm mailing list