<?xml version="1.0" encoding="windows-1252"?>
<node id="997244" title="How to export multiple packages in one file to another Perl program?" created="2012-10-04 10:47:07" updated="2012-10-04 10:47:07">
<type id="115">
perlquestion</type>
<author id="336196">
Wcool</author>
<data>
<field name="doctext">
Hi Monks.

I am writing a library of utilities to be used by Perl  scripts. The library contains some constants, some generic functions and some object oriented classes.

For practicality I like to put all these packages in one file, to make distribution easy (no subdirectories etc)

So the layout of the file looks something like this:

&lt;code&gt;
package STDLIB;
use Exporter()
some constants i like to export
some functions i like to export

package OBJECT1

some object constants i like to export like
my OBJ1_CONSTANT1;
my OBJ1_CONSTANT2;
some methods

package OBJECT2

some object constants i like to export like
my OBJ2_CONSTANT1;
my OBJ2_CONSTANT2;
some methods

1;
&lt;/code&gt;

I managed to export the generic functions and constants
but whatever I try, I can't seem to export the OO constants.

Would someone be able to show me how to do this?
Would I have to add multiple use Exporter; statements to each package? Do i have to end each package with 1; ?
Or only one Exporter statement?

And in the parent program, can restrict the import to only 1 package so something like:
&lt;code&gt;
use STDLIB qw(OBJECT1);
&lt;/code&gt;
Any pointers appreciated!</field>
</data>
</node>
