Module Questions - Confused but Why?

GAVollink on 2005-10-20T00:22:14

Modules, and namespace.

I make everything more difficult than it should be. This is something that a lot of tech heads do, and well, this is one of those things.

Without "registering" a module name, is there a 'Reserved' module space where a future module will not clobber something?

Is that even necessary, or am I being an Idiot? I've mentioned before that I'm from the land of C, and in C a module is basically a single file or a library. So, basically - a Module is anologous to a C library... (right?)

Of course, C, has explicit links and whole slew of of other ways to get around name clobbering (although, even there, it can create problems).

Worse, every time I start searching for information about making modules, everything is about making a module for CPAN... except what I'm doing is recurring database calls, that are specific to my environment.. DBD is great, and generic enough.

I'm smart enough to know that CPAN doesn't need another something::Simple

Where was I, oh yeah, Clobbering.

So I know I want to stop copying the same 10 functions between each of my web-programs, but I want to give it a module name that can't be clobbered later (we transition Linux dists often).

How does one go about this? Is there a way to set an Explicit load path for a wanted/required module? Does the naming to Module name convention have to follow the CPAN (Group=Directory)::(Module=filename.PM) mode?

So, I'm willing to read, is there some link you can point me to?


When Perl modules aren't in their normal location

clscott on 2005-10-20T04:15:21

You can use pragma called 'lib'.

In your program specify the directory where your modules are and then use them.

use lib 'privlibs'; # looks in ./privlibs
use My::Priv::Lib; #./privlibs/My/Priv/Lib.pm

More details at http://www.mathematik.uni-ulm.de/help/perl5/doc/lib.html

Re:When Perl modules aren't in their normal locati

GAVollink on 2005-10-20T13:27:58

So, this manipulates @INC as a search-path. Interesting. Learn something new every day, I do.

Thanks.

Not entirely sure I understand...

schwern on 2005-10-21T05:49:13

Are you looking for the package function?

Or are you worried that you're going to define Foo::Bar and then someone else might define Foo::Bar and this will lead to ambiguity when you say use Foo::Bar?

Re:Not entirely sure I understand...

GAVollink on 2005-10-22T00:01:31

Yeah, the second one. It's stupid, and the lib function takes care of it.

Thx,
Gary Allen