Your goals are a little contradictory. One thing Perl modules are meant to simplify is not throwing everything into the same namespace. That's why Exporter does it in a controlled fashion. As it points out,
Exports pollute the namespace of the module user.
The idea is to maintain some control over the level of sharing. But if you're going to have a thousand globals being shared, you're going against the grain of packages and modules (not to mention good programming practice).
If all you're interested in is having your program read in a bunch of variables and values, don't use modules. Instead, you can use the do function to read them in, something like this:
# stuff.pl
$fred = 'foo';
$barney = 'bar';
# ...
Later in the calling program:
#! /usr/bin/perl
# no strict unless "stuff.pl" my's everything.
# (In which case all the vars will be lexical here.)
do 'stuff.pl' or die "Couldn't read the stuff";
print $fred, "\n";
Note: I'm not recommending you implement the above code. Rather, you may want to think about why you want to share so much data, and whether there's a better way to manage it. |