perlquestion
noslenj123
I am working on a program that has several hundred constants and I'm trying to figure out a good way to include those via a required file or a used module. I've run into problems and looking for advice.<p>
If I require a file full of constants in g1.inc like<p><code>use constant FAILURE_CONF => 1;
use constant FAILURE_EVENT => 2;
use constant OPEN_REQ => 3;
use constant OPEN_CONF => 4;
1;</code>And use it like<p><code>use strict;
require "g1.inc";
if ( 3 == OPEN_REQ ) {
print "Code is OPEN_REQ\n";
} else {
print "Code is NOT OPEN_REQ\n";
}</code><p>I receive: 'Bareword "OPEN_REQ" not allowed while "strict subs"'. I had thought for some reason requiring a file is like inserting that code at that spot in the script. Is it a compiletime vs runtime issue?<p>
If I use a module, what is the briefest way to pass my large number of declared constants into the main namespace without retyping everyone of them into @EXPORT?<p>I await your witty wisdom. :-)