Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Non-standard Perl Module Locations
- Date: Thu, 13 Mar 2008 16:05:10 +0900
- From: Curt Sampson <cjs@example.com>
- Subject: Re: [tlug] Non-standard Perl Module Locations
- References: <47D7FED6.4090105@sonic.net> <20080312033943.GF2019@lucky.cynic.net> <82c89d700803112238p2f67a262red145f8c1184b881@mail.gmail.com> <47D7721F.7080107@sonic.net> <20080312151121.U1693@plexi.pun-pun.prv> <20080312033943.GF2019@lucky.cynic.net> <82c89d700803112238p2f67a262red145f8c1184b881@mail.gmail.com> <47D7721F.7080107@sonic.net> <20080312033943.GF2019@lucky.cynic.net> <82c89d700803112238p2f67a262red145f8c1184b881@mail.gmail.com>
- User-agent: Mutt/1.5.17 (2007-11-01)
On 2008-03-12 15:12 +0900 (Wed), Tod McQuillin wrote: > On Tue, 11 Mar 2008, steven smith wrote: > >> Sometimes you will have to do your include path manipulation inside a >> BEGIN block so it will get executed before you have loaded any modules >> too. > > This is why Larry invented 'use lib'. See 'perldoc lib' for details. Right. I was actually using that at first, but it gets a bit tricky when you need to dynamically generate the paths based on the the location of the file. (Much as libraries used by /usr/local/bin/program are in /usr/local/lib, I know that if I am /a/b/c/release/bin/program, my libraries are in the appropriate places under /a/b/c/release/lib.) So what I ended up doing, which may not be optimial is adding the following at the begining of each perl script in bin: BEGIN { require File::Basename; require(File::Basename::dirname($0) . "/../qam.pl"); } (I'd like to make this smaller, if anybody has any good ideas.) This is release/qam.pl: package QAM; use File::Basename; use Cwd 'abs_path'; $base = dirname(abs_path(__FILE__)); @inc_prefix = map { ($path = $_) =~ s,.*/lib/,$base/lib/,; $path } grep(/\/lib\//, @INC); foreach (reverse @inc_prefix) { unshift @INC, $_; } 1; One of the tricks of this is that the perl library paths vary quite a lot among systems, beyond just the prefix. Between my NetBSD box and Bryan's Linux box there's the obvious difference of /usr/pkg/lib versus /usr/lib, but the differences below that for, say, the architecture-specific library directory are quite dramatic: lib/perl5/site_perl/5.8.0/i386-netbsd-thread-multi versus lib/perl/5.8.0. When I install a module to be used by my programs into my project release directory with "perl Makefile.PL PREFIX=/a/b/c/release", MakeMaker uses what ever the system perl uses in terms of paths below lib. So I reckoned the easiest way to deal with that was just to look at all standard @INC paths, and duplicate them with the prefix to my release directory replacing .../lib/, e.g., /usr/lib/perl/5.8.0/ to /a/b/c/release/lib/perl/5.8.0. That's what qam.pl does. Basically, if you can find that, usually by knowing where you normally live relative to qam.pl, you're set. Thoughts? cjs -- Curt Sampson <cjs@example.com> +81 90 7737 2974 Mobile sites and software consulting: http://www.starling-software.com
- Follow-Ups:
- Re: [tlug] Non-standard Perl Module Locations
- From: David Shanahan
- Re: [tlug] Non-standard Perl Module Locations
- From: Curt Sampson
- Re: [tlug] Non-standard Perl Module Locations
- From: Marty Pauley
- References:
- Re: [tlug] Non-standard Perl Module Locations
- From: steven smith
- [tlug] Non-standard Perl Module Locations
- From: Curt Sampson
- Re: [tlug] Non-standard Perl Module Locations
- From: David Shanahan
- Re: [tlug] Non-standard Perl Module Locations
- From: steven smith
- Re: [tlug] Non-standard Perl Module Locations
- From: Tod McQuillin
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] One laptop per child
- Next by Date: Re: [tlug] Display files remotely
- Previous by thread: Re: [tlug] Non-standard Perl Module Locations
- Next by thread: Re: [tlug] Non-standard Perl Module Locations
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links