perl lib all over the place

S

Sam

Hello

I have Perl modules all over the place and I think it would be good house
keeping practice to get them all in one common dir. If that is true then how
can I do that?

Or just keep adding "use lib "/my/location";" at the top of the programs?



I have some module.pm in the following locations

/usr/local/lib/perl/5.6.1

/usr/lib/perl/5.6.1

/usr/local/lib/perl5/5.8.0/i686-linux

/usr/local/lib/perl5/5.8.0

/usr/local/lib/perl5/site_perl/5.8.0/i686-linux

/usr/local/lib/perl5/site_perl/5.8.0

/usr/local/lib/perl5/site_perl



thanks
 
K

ko

Sam said:
Hello

I have Perl modules all over the place and I think it would be good house
keeping practice to get them all in one common dir. If that is true then how
can I do that?

Or just keep adding "use lib "/my/location";" at the top of the programs?

I have some module.pm in the following locations

/usr/local/lib/perl/5.6.1

/usr/lib/perl/5.6.1

/usr/local/lib/perl5/5.8.0/i686-linux

/usr/local/lib/perl5/5.8.0

/usr/local/lib/perl5/site_perl/5.8.0/i686-linux

/usr/local/lib/perl5/site_perl/5.8.0

/usr/local/lib/perl5/site_perl



thanks

Please *don't* mess with the modules in these locations. These are the
default (built when Perl is installed) libraries that Perl searches
when you 'use' or 'require' a module/file, which can also be found in
Perl's special @INC array. If you type:

perl -e 'print "$_\n" foreach (@INC)'

You will get the same directories listed above (actually half of the
directories, since you seem to have two versions of Perl installed).

So if you're using one of Perl's core modules or have installed other
CPAN modules and haven't messed with the makefile, you should not need
to "use lib '/my/location';" in your programs as stated above.
*Usually*, you only need the 'use lib' pragma in two cases: (1)
personal libraries, or (2) if you don't have permission (no
root/administrator privileges) to install CPAN modules in the system
directories.

On an off topic note, I just saw your post regarding browsing the perl
documentation. If you don't find the 'perldoc...' interface intuitive,
may I suggest that you try http://www.perldoc.com/ ? It may be easier
to browse the documentation in HTML, and there is documentation for
the last six versions of Perl. The 'Perl Manpage' link takes you to
Perl's *core* documentation.

HTH - keith
 
K

ko

Sam said:
after installing debian, I learned that the perl version is 5.6 so
knowing perl 5.8 is out there and 6 is just around the cornor and also
knowing there is now .deb file for 5.8 yet, I downloaed the source,
compiled it and installed it, so now I have 5.8, later I knew I should
not have done that since it would upset debian way of doing things.
so I hope I did not shot my self in the foot. but if I did how can I fix
and avoid future problems?

Sorry, I don't have any experience with Debian. My *nix box is FreeBSD,
which has a package system that doesn't take mess with the default Perl
install. From the error messages you show, I'm guessing that when you
installed Perl 5.8 a link/symlink was created to reference 5.8. You
could try 'ls -l /usr/bin/perl' from your shell (substitute the full
path to Perl if its different on your system) to confirm whether my
guess is correct. If so, just change the link to point to wherever 5.6.1
resides on your system and you have your default installation back. But
I want to *stress* that this is not a Perl problem, and that you should
check one of the debian mailing lists, or post to one of the
comp.os.linux.* groups to get the real facts that will solve your problem.

Maybe you made a typo? As Tad suggested in another reply in this thread,
you can do 'perl -V'. The contents of @INC are output at the end.

perldoc lib
perldoc -q module
perldoc -q include
'How do I add a directory to my include path at runtime?'

May also be insightful.
using xemacs, perl->Run and if I don't have use lib
"/usr/local/lib/perl/5.6.1"; near the top of my module I get

cd /home/username/perl-programs/
/usr/local/bin/perl -w "/home/usrname/perl-programs/datetest.pl"
Can't locate Date/Calc.pm in @INC (@INC contains:
/usr/local/lib/perl5/5.8.0/i686-linux /usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux
/usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .)
at /home/username/perl-programs/trend.pl line 5.
BEGIN failed--compilation aborted at
/home/username/perl-programs/datetest.pl line 5.

Compilation exited abnormally with code 2 at Sat Sep 20 08:39:55

Here's another (bad) way to find out what is in @INC, and it shows that
you're running 5.8. You should also be aware that in some cases modules
need to be compiled for specific versions of Perl - your 'use lib..' is
using the Date::Calc module built for 5.6.1 (I don't think this is a
problem with Date::Calc, if I'm wrong, someone please correct me).

Good luck - keith
 
S

Sam

ko said:
"Sam" <[email protected]> wrote in message


Please *don't* mess with the modules in these locations. These are the
default (built when Perl is installed) libraries that Perl searches
when you 'use' or 'require' a module/file, which can also be found in
Perl's special @INC array. If you type:

perl -e 'print "$_\n" foreach (@INC)'

You will get the same directories listed above (actually half of the
directories, since you seem to have two versions of Perl installed).

So if you're using one of Perl's core modules or have installed other
CPAN modules and haven't messed with the makefile, you should not need
to "use lib '/my/location';" in your programs as stated above.
*Usually*, you only need the 'use lib' pragma in two cases: (1)
personal libraries, or (2) if you don't have permission (no
root/administrator privileges) to install CPAN modules in the system
directories.

On an off topic note, I just saw your post regarding browsing the perl
documentation. If you don't find the 'perldoc...' interface intuitive,
may I suggest that you try http://www.perldoc.com/ ? It may be easier
to browse the documentation in HTML, and there is documentation for
the last six versions of Perl. The 'Perl Manpage' link takes you to
Perl's *core* documentation.

HTH - keith


in regarding to browsing the perl docs. www.perldoc.com does not support
packages which is not part of the core perl disto...correct?
if so, do I have another chance with not core modules.
I am now using $man Date::Calc and it has above 60 items in the main
array, I would like to be able to click on an item and it takes me to
more explanation about what it is and it does. it is very hard when I
cann't even search the man page of a module or can I?
 
K

ko

Sam said:
in regarding to browsing the perl docs. www.perldoc.com does not support
packages which is not part of the core perl disto...correct?
if so, do I have another chance with not core modules.
I am now using $man Date::Calc and it has above 60 items in the main
array, I would like to be able to click on an item and it takes me to
more explanation about what it is and it does. it is very hard when I
cann't even search the man page of a module or can I?

Besides serving as a repository for modules, CPAN has a nice search
feature and has HTML documentation:

http://search.cpan.org/

Not sure what you mean when you say that you can't search the manpage
of a module. I know you're new to Perl and *nix and I can definitely
relate to sometimes being overwhelmed by learning so many new things
at once, but I *strongly* suggest that you hit learning your OS shell
commands harder because some of the questions you've been posting are
not strictly Perl related. Consequently, your questions may start to
go unanswered. Its time-consuming and at times frustrating, but I find
that I learn a lot more by spending that extra bit of time trying to
find/fix my mistakes/problems rather than having someone else give me
the answers. You tend to remember something that took you an hour to
fix :) And you *can* search any manpage on your system, since man uses
a pager program (more, less, etc) that has search capabilities.

One last thing. Learn Perl's *basic* concepts and contructs before you
start trying to use higher level contructs and modules. I think I saw
in one of your other posts that you have 'Programming Perl'? Read the
first few chapters over and over till you understand. Don't take this
personally - I had to do the same and still browse through them from
time to time. The point being that you can't expect to write a script
of any level of complexity without *first* knowing the basics. The
experts in the group 'preach' what some newcomers feel is 'dogmatic
programming' for good reason - it saves you time and frustration in
the end, and makes you a better programmer.

You seem really motivated to learn Perl, so good luck - keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top