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.