Since modules are loaded before your program executes, if you are setting %ENV in your program, by the time it gets set, the module is already loaded.
You have several options:
- Provide a method in your module such that your program can call it, and set the variable
- Pass the parameter with the "use statement" i.e. "use mymodule qw/3.0/;" Then the 3.0 will be passed to the import method of your module.
But you need to be aware that this again happens before your program executes, so dont pass anything that is not a constant and available at compile time.
- Make an "our" variable in your module (our $VER), and explicitly set it in your program via $ModuleName::VER = "0.3" (not recommended)
- I'm sure Other monks will jump in here and provide more.
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992