This will work if an existing variable needs to be modified. My problem is that I want to set a new environment variable by invoking a batch file from a perl script. I don't know what's inside batch file before invoking the batch file. So I cannot use work around of $ENV{'envvariable'} = 'soandso'; in perl.
I also tried pl2bat function converting my whole perl script to a batch file, it ran successfully but the behavior of environment variables is the same as before. The enviroment variables are not set. | [reply] |
I did not say it solved your problem; I said that it shows how you can accomplish this.
It sounds like the easiest solution (given that you are so reluctant to admit that you can read the contents of your setEnv.bat) would be to add "call setEnv.bat" to the preamble that pl2bat would add to your Perl script.
| [reply] |
Thanks for the reply. How can I include "call setEnv.bat" inside a subroutine of perl - the pl2bat sure generated a .bat file, but the subroutines are still subroutines right? Can I just stick in a statement "call setEnv.bat" inside a subroutine in the generated bat file?
| [reply] |
| [reply] |
If I invoke the batch file from inside another batch file - I can do this. Lets say I have batch2.bat the inside of which looks like:
@echo off
set TEST_ENV=true
I have another batch file setEnv.bat the inside of which looks like:
@echo off
call batch2.bat
after executing setEnv.bat on command line
if I do "set TEST" it will print: TEST_ENV=true
The same thing if I do from perl like :
my $cmd = "call setEnv.bat";
system( $cmd );
and call the perl script from command line.
then do "set TEST"
It will print : "Environment variable TEST not defined"
| [reply] |