Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
When you use system or backticks or qx{}, the command is executed in a newly spawned shell, so setting an environment variable using one of these methods will not reflect to the calling process. Consider it to be equivalent to (I used $$ to show that it is the prompt of the sub-shell)
So, those three are out. The case of %ENV is way more interesting, as it involves scope and timing. Lets start with simple examples:
You can observe that the proces spawned with the first qx uses the original value stored in $A, and the second invocation uses the changed value, as you expect (if I read your question correctly), so no surprises there. What will complicate matters is if those %ENV values are used in the startup phase of a module that you use. This implies that the value is used before you change its value. In that case, you should do something like
Now the environment is set before it is seen by the module. HTH Enjoy, Have FUN! H.Merijn In reply to Re: setenv in perl
by Tux
|
|