Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by fishmonger (Pilgrim)
on Jan 30, 2014 at 17:41 UTC ( #1072709=note: print w/ replies, xml ) Need Help??


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
Re^4: Clean way to export all constants at once
by perl_help26 (Sexton) on Jan 31, 2014 at 08:29 UTC

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072709]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-12-26 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls