finding modules via @INC

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to use an XML pretty printer called xmlpretty on UNIX that
I downloaded from the net.  xmlpretty is a simple perl program that
uses a module called that came with the package.  So
xmlpretty has:

use XML::Handler::YAWriter;

However, with xmlpretty and in the same directory and
running xmlpretty from this directory, perl complains it can't find

$ export PERL5LIB=`pwd`
$ xmlpretty
Can't locate XML/Handler/ in @INC (@INC contains: /home/
-Handler-YAWriter-0.23 /usr/perl5/5.00503/sun4-solaris /usr/
perl5/5.00503 /usr/p
erl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at
xmlpretty line 4.
BEGIN failed--compilation aborted at xmlpretty line 4.

Note that @INC is set to the current directory twice - first with the
PERL5LIB and the default addition of the current directory (.) to this
search path.

However, if I run the xmlpretty directly with the perl command and use
the -l option to specify the current directory, it works (and fails if
I leave the -l option off):

$ perl -l `pwd` xmlpretty

Can anyone tell me what I need to do to be able to run xmlpretty
directly and have it find the module that is in the same

Here is my perl version:
This is perl, version 5.005_03 built for sun4-solaris


Re: finding modules via @INC wrote:
Quoted text here. Click to load it

It's a module, and not supposed to be placed in the same directory as
the script. The best you can do is to install XML::Handler::YAWriter
properly, e.g. using

Another option is to create a directory XML in
/usr/perl5/site_perl/5.005, then create a subdirectory Handler in the
XML directory and place there. Then you should have:


Gunnar Hjalmarsson

Re: finding modules via @INC

Quoted text here. Click to load it

Read the error message. It's looking for a file XML/Handler/
under one of the directories listed, so create a directory XML/Handler
in the current directory and put in there.

Note that Gunnar is right that since this is apparently a CPAN module it
would be better to install it properly. If you can't (or don't want to)
install into the system perl directories, you can use something like

    perl Makefile.PL INSTALL_BASE=~
    make test
    make install

to install it in bin/ and lib/ directories under your home directory.
You will need to set PERL5LIB=~/lib/perl5 and PATH=~/bin.

Quoted text here. Click to load it

I don't know what makes you think -l 'specifies the current directory'.
-l does something quite different and I would be very surprised if it
affected your problem. Did you perhaps mean -I?

Quoted text here. Click to load it

This is a seriously old version of perl. It was released nearly 10 years
ago, and relatively little CPAN software will be tested with it. You
should really see if you can get a newer version installed: it's
perfectly possible to do this without replacing the system perl, as that
would usually be a bad idea.


Site Timeline