Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by fishmonger (Chaplain)
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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072709]
help
Chatterbox?
[choroba]: Playing in a punk rock band for 20 years... my hearing is quite bad
[Corion]: I still have hopes to turn my godson and his two siblings into a punk band ;)
[Corion]: Their older sister just started piano but has been interested in drumming, which she should be able to start with 8 years or so)
[Discipulus]: ah was Kink of Bongo 1992..
[1nickt]: choroba name of band? youtube link? MySpace link?
[Your Mother]: I like Manu Chao.
[Your Mother]: I like this one quite well, https://www. youtube.com/watch? v=rSEUH4KRfN8

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2017-03-24 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (301 votes). Check out past polls.