in reply to Using constants in multiple scripts
You mention that the error occurs when you started to use a package, but you didn't show any package declaration in your code. A first guess would be that the constant is defined in one package, but used in another one, and that you did not import it.
Does anyone have a better suggestion to approaching using constants in this way?
"Better" is often a matter of taste. Here is how I use constants in my current project:
Instead of using use constant, I have installed the Readonly module from CPAN. I declare a constant in one package like this:
and refer to it from another package like this:package Glogg; Readonly our $myconst => "goofy";
Of course I could also export it if I don't want to refer to it via the package name.package Drull; print("$Glogg::myconst\n");
|
|---|