Home > Archive > PERL Miscellaneous > June 2004 > Modules and different paths
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Modules and different paths
|
|
| Mark Seger 2004-06-28, 8:58 pm |
| I'm trying to use Compress::Zlib in a script I'm trying to run on a
number of platforms. Depending on which version of Compress and perl
are being used, more often than not it seems Zlib gets installed in a
direction not in the current @INC - the most common being ending up in a
5.6 directory on a 5.8 system or visa-versa and it's driving me and the
users of the script crazy.
The thought I had was in the initialization section to look in specific
known locations to figure out where Zlib ended up and then add that
location to @INC. right? I thought I'd try to be clever and use the
lib module to set INC but to do that at run vs compile time I have to do
it in a require. No problem, or so I thought, but if I can't figure out
the syntax! My thought was since the syntax for 'use' is
use lib 'path';
I could say
require "lib 'path'";
but that doesn't seem to do it. So I guess my multipart question is:
- is this a reasonable way to deal with rpms that install into multiple
locations?
- is the correct way to set my path dynamically to 'require lib' and if
so what is the correct syntax?
- is there a way to get an rpm to install in a directory I want it to
rather than the ones it wants to?
-mark
| |
| A. Sinan Unur 2004-06-28, 8:58 pm |
| Mark Seger <Mark.Seger@hp.com> wrote in
news:40e07ed7@usenet01.boi.hp.com:
> I'm trying to use Compress::Zlib in a script I'm trying to run on a
> number of platforms. Depending on which version of Compress and perl
> are being used, more often than not it seems Zlib gets installed in a
> direction not in the current @INC - the most common being ending up in
> a 5.6 directory on a 5.8 system or visa-versa and it's driving me and
> the users of the script crazy.
>
> The thought I had was in the initialization section to look in
> specific known locations to figure out where Zlib ended up and then
> add that location to @INC. right? I thought I'd try to be clever and
> use the lib module to set INC but to do that at run vs compile time I
> have to do it in a require. No problem, or so I thought, but if I
> can't figure out the syntax! My thought was since the syntax for
> 'use' is
>
> use lib 'path';
>
> I could say
>
> require "lib 'path'";
Did you check:
perldoc -q lib
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
| |
| Mark Seger 2004-06-28, 8:58 pm |
| A. Sinan Unur wrote:
> Mark Seger <Mark.Seger@hp.com> wrote in
> news:40e07ed7@usenet01.boi.hp.com:
>
>
>
>
> Did you check:
>
> perldoc -q lib
>
>
no I didn't 8-( and it is very informative, but only if you're
building from source. I probably should have been clearer that I'm
trying to have people simply install prebuilt rpms and it's those very
rpms that have specific places they stash their code in.
-mark
| |
| A. Sinan Unur 2004-06-28, 8:58 pm |
| Mark Seger <Mark.Seger@hp.com> wrote in news:40e08909$1
@usenet01.boi.hp.com:
> A. Sinan Unur wrote:
....[color=darkred]
>
> no I didn't 8-( and it is very informative, but only if you're
> building from source. I probably should have been clearer that I'm
> trying to have people simply install prebuilt rpms and it's those very
> rpms that have specific places they stash their code in.
I might be misunderstanding something here, but:
use strict;
use warnings;
use File::Spec::Functions qw(catfile);
BEGIN {
sub find_my_lib {
catfile($ENV{TEMP}, 'lib');
}
}
use lib find_my_lib();
use MyClass;
my $t = MyClass->new('Hello World!');
use Data::Dumper;
print Dumper $t;
__END__
C:\Home> t
$VAR1 = bless( do{\(my $o = 'Hello World!')}, 'MyClass' );
Does this help?
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
| |
| Ben Morrow 2004-06-28, 8:58 pm |
|
Quoth Mark Seger <Mark.Seger@hp.com>:
> I'm trying to use Compress::Zlib in a script I'm trying to run on a
> number of platforms. Depending on which version of Compress and perl
> are being used, more often than not it seems Zlib gets installed in a
> direction not in the current @INC - the most common being ending up in a
> 5.6 directory on a 5.8 system or visa-versa and it's driving me and the
> users of the script crazy.
NOTE that 5.6 and 5.8 are not binary-compatible, which is why the 5.6
lib dir is not searched by default by 5.8. If your rpms are installing
in a 5.6 dir, are they installing modules built for 5.6?
> The thought I had was in the initialization section to look in specific
> known locations to figure out where Zlib ended up and then add that
> location to @INC. right? I thought I'd try to be clever and use the
> lib module to set INC but to do that at run vs compile time I have to do
> it in a require. No problem, or so I thought, but if I can't figure out
> the syntax! My thought was since the syntax for 'use' is
>
> use lib 'path';
>
> I could say
>
> require "lib 'path'";
>
> but that doesn't seem to do it.
Try
require lib;
import lib 'path';
This *is* better than simply pushing onto @INC, as it will also find
arch directories.
> So I guess my multipart question is:
> - is this a reasonable way to deal with rpms that install into multiple
> locations?
Err... I would say, no, fix the rpm or install from source (I manage all
perl modules on my system with CPAN.pm, and don't use my package manager
for them at all).
> - is there a way to get an rpm to install in a directory I want it to
> rather than the ones it wants to?
Dunno, I'm afraid... I stay as far from rpms as possible :).
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk
|
|
|
|
|