in reply to Catch references to undefined variables in other modules?

The best practice is:

use a qw( $x $z );

which produces, at compile time (for a properly written a.pm):

"$z" is not exported by the a module Can't continue after import errors at -e line 1

Here is the example a.pm I used:

package a; require Exporter; *import= \&Exporter::import; our @EXPORT_OK= qw( $x ); our $x= 'x'; 1;

- tye        

Replies are listed 'Best First'.
Re^2: Catch references to undefined variables in other modules? (export)
by Anonymous Monk on Oct 31, 2007 at 16:52 UTC
    Do you have any suggestions other than Export if I've got about 800 constants defined in my 'Constants.pm' module and 400 modules which use them? Each module is only importing the constants it needs, but I still would like to avoid creating all those extra symbol table entries and still catch misspelled names at compile time.
      Each module is only importing the constants it needs, but I still would like to avoid creating all those extra symbol table entries

      If each module is only importing a few, then you are only creating a few extra symbol table entries. So I don't see what you are optimizing here. It isn't like symbol table entries take a huge amount of space. A few more per module isn't going to be much compared to the size of the module.

      - tye