From: Paul Tremblay <[EMAIL PROTECTED]>
> I have a series of modules in a directory that I will call Rtf2xml. (I
> checked on Cpan, and don't believe this name space is taken.)
>
> I named each module by a simple name--for example Pict.pm. In the main
> script, I have:
>
> use Rtf2xml::Pict
> ...
> &Pict::process_pict()
>
>
> In the actual module, I have:
>
> package Pict;
>
>
> Everything works fine this way. But when I look at other modules, I
> notice that they use a different naming convention.
>
> My question is if I should follow this syntax:
>
> package Rtf2xml::Pict # for the actual module
>
> &Rtf::Pict::process_pict() # for calling on a subroutin in the pacage
Definitely. If the module is in .../lib/Rtf2xml/Pict.pm then
everybody will assume the package is Rtf2xml::Pict. Including Perl!
If you want to be able to use Exporter (or even your own code) to
export some functions to the script so that it doesn't have to use
the Rtf2xml::Pict:: you HAVE to use the right package name.
It would be best if your module started with something like
package Rtf2xml::Pict;
use strict;
require Exporter;
use vars qw(@ISA @EXPORT_OK);
@ISA = qw(Exporter);
# inherit the import() from Exporter.pm
@EXPORT_OK = qw(process_pict ...);
# list of things to export if asked to
...
and in the script you may then do
use Rtf2xml::Pict qw(process_pict);
process_pict(...);
Another thing ... if you plan to distribute a module it's best to use
h2xs to generate a "stub" for you.
h2xs -A -X -f -n Rtf2xml::Pict
will create
./Rtf2xml
Pict
Makefile.PL
Changes
MANIFEST
Pict.pm
t/1.t
and fill the files with defaults. It's much easier to modify those to
fit your needs than to try and create everything yourself.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]