Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: code that runs at module loading

by rrwo (Friar)
on Dec 07, 2004 at 20:34 UTC ( [id://412998]=note: print w/replies, xml ) Need Help??


in reply to Re: code that runs at module loading
in thread code that runs at module loading

Having the script that uses the constant generate the code at compile time (in a BEGIN block) is one of the wonderful features of Perl that distinguishes it from other languages. Why not make use of it?

Replies are listed 'Best First'.
Re^3: code that runs at module loading
by sgifford (Prior) on Dec 07, 2004 at 21:06 UTC
    I was just throwing out a technique I use sometimes to see if the OP might find it useful; it's not necessarily the best strategy here. It's useful if the constants take a long time to generate, or if they're actual use constant declarations, which Perl can optimize away at compile-time if it knows them beforehand.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2025-01-18 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (56 votes). Check out past polls.