http://www.perlmonks.org?node_id=1072709


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

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.

  • Comment on Re^3: Clean way to export all constants at once

Replies are listed 'Best First'.
Re^4: Clean way to export all constants at once
by perl_help26 (Beadle) on Jan 31, 2014 at 08:29 UTC

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