in reply to Re: Clean way to export all constants at once
in thread Clean way to export all constants at once

Thank you for the fast reply :D ... I realize that i still have to list the constants once in global_constants.pm or else it gives me an error

our @EXPORT_OK = ('CURRENTCHANGE','BLDNUM','STAGEROOTDIR','WEBREPORTDI +R'); our %EXPORT_TAGS = (all => \@EXPORT_OK);

This is great but can I push it further so that I wouldn't have to list even in global_constants.pm? Thanks a lot.

Replies are listed 'Best First'.
Re^3: Clean way to export all constants at once
by fishmonger (Chaplain) on Jan 30, 2014 at 17:41 UTC

    Instead of using the constant pragma, I'd use the Readonly module and create a readonly hash which is exported.

    You could even take it a step further and define individual lexical scalars in your module and export a readonly dispatch table of anonymous subs that return the individual scalar values.

    You may also want to read this review http://neilb.org/reviews/constants.html of 21 different modules that can be used to define constants.

      Readonly seems fine but I prefer tobyinc's way ...Thanks for the reply

Re^3: Clean way to export all constants at once
by toolic (Bishop) on Jan 30, 2014 at 16:51 UTC
    You might be able to use Readonly to built up a list of constant names.