in reply to How to import constants from another perl script
We'd really need to see the code in order to explain what is or isn't happening.
Having said that, it would be better to put them in a separate module file (e.g. MyConstants.pm) then use MyConstants;. This allows you to use your constants in whatever scripts you want without polluting your namespace with whatever else is in globals.pl.
You can then make a decision whether you want to export the constants automatically (not generally recommended), export them on request (a much better alternative) or you can access them by name (e.g. MyConstants::ERROR).
Here's some doco that may help: constant, Const::Fast, Readonly and Exporter.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to import constants from another perl script
by stevenswj (Initiate) on Nov 01, 2010 at 06:22 UTC | |
by Anonymous Monk on Nov 01, 2010 at 08:54 UTC | |
by thargas (Deacon) on Nov 01, 2010 at 13:09 UTC | |
by Anonymous Monk on Nov 01, 2010 at 14:24 UTC |