in reply to Importing Symbol Tables

Using Exporter isn't really a huge hassle, since you can virtually auto-import if you declare them using something other than a whole whack of variables.

Something to consider is using a global hash instead of a thousand global variables. Then you can have virtually unlimited access to "globals" without having to explicitly declare them.

Further to that, if you really have thousands of "constants", these should probably come from a config file anyway, unless, of course, these are strictly related to the internals of the program.

The more ambitious approach is to write your own import function and stuff references to your globals into the calling module. Consider:
package Foo; our $a = "a"; our $b = "b"; sub import { my ($self) = @_; my ($caller_package) = caller; foreach (keys %{"${self}::"}) { *{"${caller_package}::$_"} = *$_; } }
Now this will export everything that is exportable, that being those things declared with our instead of my.

Replies are listed 'Best First'.
Re: Re: Importing Symbol Tables
by moebius (Novice) on Mar 27, 2002 at 03:26 UTC
    Thans to everyone for their comments thus far. Let me say that this is only an idle project that I am mussing with just to see how it all works. This will /not/ be production code...ever.

    My goal with this is mainly focused around better understanding the minutiae of packages and symbol tables. Controlling exports/imports between packages seems like an interesting test to me.

    Thanks again, and fear not, this project is a test only. You have given me much to ponder in the meantime. Keep em coming.

    Your humble apprentice.