Thanks for your answer Bob! 0-)

However, I already had this set up as you describe and I am getting a 
"requires explicit package name" error when I try to use a variable from 
the module exporting its variables.

There are two differences that I see between what I did and what you show:
         The first is that I am using "use Exporter" vs. "require 
Exporter".     I made this change just to see if that was my problem, but 
it was not.

         The second is that I am specifying a subroutine on the importing 
module's 'use' statement.

Below is what I have.

Export module:
package SI::env;

use strict;
use vars qw(
   @ISA @EXPORT @EXPORT_OK $Debug
   $mysqlhost $mysqluser $mysqluser $mysqlpass $db_prefix
);
use subs qw(get_site);

use Exporter;

@ISA = qw(Exporter);

@EXPORT = qw(
   $mysqlhost $mysqluser $mysqluser $mysqlpass $db_prefix
);

@EXPORT_OK = qw(debug_Print die_error get_site print_env);

,,,

Import module:
package SI::database;

use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $Debug $dbh);

use Exporter;
use DBI ();
use SI::env qw(die_error);

@ISA = qw(Exporter);

@EXPORT = qw($dbh);

@EXPORT_OK = qw(db_connect read_table update_raw_database);

...


At 04:57 PM 10/29/01 -0500, you wrote:
> > -----Original Message-----
> > From: Walter Grace [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, October 29, 2001 3:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: Exported variables
> >
> >
> >
> > I have a variable in a module that I export (e.g. @EXPORT =
> > qw( $variable ); )
> >
> > Do I have to de-reference (terminology?) it in any other
> > modules or scripts
>
>"fully qualify" not "de-reference"
>
> > that include the given module (ie. $module::variable) or is
> > there a way to
> > import the variable so that I can refer to it directly?
>
>That's the whole idea behind @EXPORT.
>
>There are three ingredients to exporting symbols:
>
>1. Your module needs to inherit from Exporter. This is done by adding
>    "Exporter" to @ISA:
>
>    require Exporter;
>    our @ISA = qw(Exporter);
>
>2. You need to include the symbols to be exported in @EXPORT or
>    @EXPORT_OK.
>
>    @EXPORT_OK = qw($foo $bar $baz);
>
>3. Users of your module need to bring it in with "use":
>
>    use MyModule;
>
>"use" does two things: 1) require() your module, and 2) call your module's
>import() method. Since your module inherits from Exporter and normally does
>not override the import() method, Exporter's import() method get's called.
>It's default behavior is to export all the symbols defined in @EXPORT_OK
>to the package namespace which did the "use".
>
>If you do these 3 things, you can refer to $foo, $bar, and $baz without
>qualifying with a package name, since an alias for those symbols was
>created in your current package.
>
>For lots more info, see
>
>    perldoc -f use
>    perldoc Exporter
>    perldoc perlmod

Reply via email to