in reply to
%ENV in a .pm versus .cgi ?
The question is a bit under-constrained since we have no code to review, but a few possibilities:
Are you testing the module and script in the same environment? If you run the script command-line, and run the module under Apache context, %ENV will and should vary.
Your code may be localizing some values of %ENV. This is actually a good security practice, since it's a potential exploit channel. See perlsec.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.