http://www.perlmonks.org?node_id=1038284

gj2666 has asked for the wisdom of the Perl Monks concerning the following question:

I inherited a win (2003) perl (5.16.2) build script combining steps in a build process for multiple apps. For one of the apps we build with Gradle.
I'm having a difficult time with the environment setup. Here's a snip...
if ($pvob eq "XYZ"){...} else { open("..\\abc-env\\setenv.cmd"); system(set); system("gradle"); ...}
I know that the open is in one (session/stream/fork/process?) and that as soon as it returns, all the environment it has just set is lost. I did the "system(set)" to confirm that point.
So when I execute the "gradle" it fails because there isn't anything in the env session where the system("gradle") is executed.
I read the "open()" perl doc and it looked like maybe you could create a pseudo filehandle that could be reused later in the calling script. But that sounded too good to be true. if so, syntax? Redirect or pipe new command into the filehandle?

I understand what open() or system() etc. is doing, but I've never really understood how to work with the configuration of such a temporary environment. The env is set for each build target so setting it at the os level doesn't really work for me in this case.

Any suggestions for getting the env variables to be persistent from within the build script would be appreciated.
(Or I suppose, help with syntax on stringing together the commands in the same open()?). This script has never worked for this app. (btw first thing I did was put in use strict and warnings so if you've taught me nothing, you've taught me that.)