At 00:01 26.10.2002, Robert Covell wrote:
I have read that link you provided, thanks.

The modules I have declared do contain a package name.

Is it not possible or easy to just use/require/include a pl or pm file that
contains a set of function for me to reuse.

Is this a valid pm and pl file?



package Test;

sub DisplaySection {
        print $_[0];
}

1;


and in my pl file(without the other stuff to make it run):

use Test;
&DisplaySection("Test12");
Some comments:
- Don't use the name Test. It's a module already provided with the perl distribution, and there will therefore be subtle conflicts.
- I don't see how the above code could work in any case: you declare the subroutine in the package Test, and then you call it in the package used for the registry script. Unless you define another subroutine DisplaySection in that package, there is no way for Perl to find the correct subroutine.
The correct thing would be:

package My::DisplayModule;
... same as before ...
1;

and in the script:
use My::DisplayModule;
My::DisplayModule::DisplaySection("Test12");

This is of course only one of many ways of doing it. I would suggest reading up on general Perl documentation regarding modules and package, such as perlmod, perlmodlib, perlboot, perltoot, perltooc, perlbot ... Just read on :) But you really need to learn this to work correctly with Perl, and especially with mod_perl. As Perrin also mentioned, there are some subtleties with the way packages work under mod_perl that are explained in the 1.0 user's guide.

-----Original Message-----
From: Perrin Harkins [mailto:perrin@;elem.com]

It sounds like you are using perl4-style libs that don't declare a
package name.  You can find a description of the problem and some
solutions here:
http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modu
les_and_libs

The basic fix is to give your modules unique package names.  See the
perlmod man page for more on package names.
--
Per Einar Ellefsen
[EMAIL PROTECTED]


Reply via email to