in reply to Windows environment variable not set if calling from a perl program

There are two possibilities to do what you are trying to do:

  1. Have whomever writes the batch files that change the environment variables switch to writing short perl scripts that do it;

    and then invoke those batch-file-substitute scripts from perl using do setEnv.pl

  2. write a batch file parser in Perl, and interprete the batch scripts yourself.

    Be aware that despite its apparent simplicity, batch script is surprisingly complex.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Windows environment variable not set if calling from a perl program
  • Download Code

Replies are listed 'Best First'.
Re^2: Windows environment variable not set if calling from a perl program
by svasa (Initiate) on Dec 10, 2015 at 14:49 UTC
    Thanks. Unfortunately not everybody who writes those batch scripts can write perl scripts. What I am doing for now is I have a windows batch script which calls perl program periodically ( basically perl became an utility now rather than the driving program ) the batch script is the driving program now. In this case I can set env variables. But yes writing such a complex program in batch is excruciatingly painful. I find it very easy in Perl.