<html><body><p>I'm doing pretty much the same thing, although I dislike the fact that declaring/exporting constants tends to be very verbose.  You have to name those constants both in &#34;use constant&#34; and when declaring them in EXPORT_OK and/or EXPORT_TAGS.</p><p>The following sample is what suits me best for now:</p><pre>package TF::Constants;

use strict;
use warnings;

use base 'Exporter';

our %PERMISSIONS;
our %ERRORS;

our %EXPORT_TAGS = (
    perms  =&#62; [ keys %PERMISSIONS ],
    errors =&#62; [ keys %ERRORS ]
);

our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS;

$EXPORT_TAGS{all} = \@EXPORT_OK;

### &#34;use constant&#34; implies a BEGIN block, so unless we declare our
### variables in a BEGIN block they won't be defined by the time
### constant::import is called.  Still learning Perl quirks after 8
### years.

BEGIN {

    %PERMISSIONS = (

        TF_PERM_EXEC_OTHER   =&#62; 1,
        TF_PERM_WRITE_OTHER  =&#62; 2,
        TF_PERM_READ_OTHER   =&#62; 4,

        TF_PERM_EXEC_GROUP   =&#62; 8,
        TF_PERM_WRITE_GROUP  =&#62; 16,
        TF_PERM_READ_GROUP   =&#62; 32,

        TF_PERM_EXEC_USER    =&#62; 64,
        TF_PERM_WRITE_USER   =&#62; 128,
        TF_PERM_READ_USER    =&#62; 256,

        TF_PERM_DEFAULT      =&#62; 0664, # rw-rw-r--

    );

    %ERRORS = (
        TF_ERR_NOPERMS =&#62; 'NOPERMS',
    );

}

use constant \%PERMISSIONS;
use constant \%ERRORS;

1;</pre><p>That is in short: declare some global (<b>our</b>) hashes, that contain your constants.  Then define them in a BEGIN block.  Then pass reference to those hashes to <b>use constant</b> and finally, use some <b>map</b>/<b>keys</b> tricks to export them automatically (not having to list each name again is a big win for my lazy ass).</p><p>Cheers,<span id="DYNARCHLIB_RTEFRAME_CARET"></span><br/>-Mihai</p><p><span id="DYNARCHLIB_RTEFRAME_CARET"></span>PS: yes this is totally unrelated to Catalyst. :-)</p><p>Tomas Doran <a href="mailto:bobtfish@bobtfish.net">bobtfish@bobtfish.net</a> wrote:</p><blockquote><p>Jarom Smith wrote:</p><blockquote><p>In the end, this is what I decided to do because I have relatively few of these guys (so far) and I'd rather have them thrown together all in one place than spread all over the system. But I'm wondering if there is a best practice?</p><p>I don't want to put them in the config hash or in a configuration file because these are not things that a user should be able to change or override.</p></blockquote><p>Not sure this is the 'best practice' way of doing what you're trying to achieve, but that aside - to answer your actual question:</p><p>I'd just put them all into their own package, and arrange for them to be exportable, something like this:</p><p>package MyApp::Constants; use strict; use warnings; use Exporter qw/import/;</p><p>use constant { THING<em>FOO =&#62; 0, THING</em>BAR =&#62; 1, };</p><p>our @EXPORT = qw( &#38;THING<em>FOO &#38;THING</em>BAR );</p><p>then just 'use MyApp::Constants;' where you need them, job done..</p><p>Cheers t0m</p><hr/><p>List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/</p></blockquote></body></html>