Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Win32 Perl fail to see the set ENV in loaded module

by kartlee05 (Novice)
on Apr 25, 2014 at 16:51 UTC ( #1083810=perlquestion: print w/replies, xml ) Need Help??
kartlee05 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Folks, I try to set an ENV in BEGIN block and load a module. The dll loaded by the module does't see the env. If I run system("set"), just after the env is set, I do see the env in the list. Is there a bug in perl win32 in handling environment through cached block that affect the module from seeing it?
#!/usr/bin/env perl BEGIN { $ENV{TEST} = "CHECK"; require module; # use module; doesn't work too. } print module::check_env(), "\n";
-Karthik

Replies are listed 'Best First'.
Re: Win32 Perl fail to see the set ENV in loaded module
by Lotus1 (Priest) on Apr 25, 2014 at 17:21 UTC
      I see the reported issue only for Windows. BTW, I updated the ticket with the code. Please check.
Re: Win32 Perl fail to see the set ENV in loaded module
by mr_mischief (Monsignor) on Apr 25, 2014 at 17:28 UTC

    By "load a module" do you mean using use module; or require module;? The use happens at compile time. A require on the other hand works at runtime.

    Seeing the actual code may be helpful.

      I just updated the ticket with the code. 'use' or 'require' seem to be behaving same in this case.

        I don't have Windows handy to test at the moment. It is my suspicion that the DLL is grabbing the environment from somewhere other than the current process. The module itself should be reflecting the current process's environment since it is part of the current process.The BEGIN block shouldn't even be necessary.

        Since you're working with a specific DLL, you may want to check the programmer's documentation for that DLL.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1083810]
Front-paged by Arunbear
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-07-17 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (353 votes). Check out past polls.

    Notices?