The way I used to do it was to essentially use a source filter: I'd have a BEGIN block inside my Definitions.pm file read the file itself in and look for "use constant" lines:package Constants; use base 'Exporter'; our @EXPORT = grep { substr( $_, 0, 2 ) eq 'C_' && __PACKAGE__->can( $_ ); } keys %Constants::;
Anyone doing a lot of work with perl constants might want to skim through those talk notes, by the way. And in general, these days I'd recommend staying away from constants altogether -- their utility rarely makes up for their annoyances (e.g no sigil, so they don't interpolate very smoothly). Also a case can be made for keeping definitions of things in a YAML file instead of using perl code to store configuration (programmatic modification of YAML is a lot easier than parsing perl).
In reply to Re^2: How to include a large number of constants?
by doom
in thread How to include a large number of constants?
by noslenj123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |