in reply to Clean way to export all constants at once
package global_constants; use strict; use warnings; my %constants; BEGIN { %constants = ( LOAD_ARABIC => 1, LOG_USERS_ACTIONS => 1, ENABLE_RCSE => 1, ); } use constant \%constants; use base 'Exporter'; our @EXPORT = (); our @EXPORT_OK = keys(%constants); our %EXPORT_TAGS = ( all => \@EXPORT_OK, default => \@EXPORT, log => [ grep /^LOG_/, @EXPORT_OK ], # all constants beginning +with "LOG_" ); 1;
And then in a module that uses it:
use global_constants qw( :all );
Another module that only needs to import the LOG_* constants, and one other one:
use global_constants qw( :log ENABLE_RCSE );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Clean way to export all constants at once
by perl_help26 (Beadle) on Jan 31, 2014 at 08:27 UTC |