Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Re: .bat and perl mystery

by jsprat (Curate)
on Jun 12, 2002 at 17:57 UTC ( #173944=note: print w/replies, xml ) Need Help??


in reply to Re: Re: .bat and perl mystery
in thread .bat and perl mystery

As you've found out, you can't set environment variables in the parent process. When you try, you spawn a new command process, set the environment variable and exit that process, losing whatever changes you made (see perldoc -q environment or here).

What you can do is use the %ENV hash to set the environment before using VS to build your project.

I can't remember what vcvars32.bat sets, but something like this:

$ENV{LIB}='D:\VCDIR\LIB;' . $ENV{LIB}

should work, as long as it is set before you begin the build.

Replies are listed 'Best First'.
Re: Re: Re: Re: .bat and perl mystery
by Anonymous Monk on Jun 13, 2002 at 12:35 UTC
    Sorry, I'm not sure I quit understand. Should I create a child process solely for the execution of the .bat file and the use the parent process to continue running the main script?
      Make the changes in the script, before you start the build. These changes will be visible in any child process.
      sub Build { # my $vcvars32 = 'VCVARS32.BAT'; << comment out these # system ($vcvars32); << two lines # set your environment variables (the same ones # vcvars32.bat sets) like so: $ENV{LIB} = 'D:\MSVCDIR\LIB;'.$ENV{LIB}; $ENV{PATH} = 'D:\MSVCDIR\BIN;'.$ENV{PATH]; system $command; # this now sees the variables set above

      check perlvar for a little more info on %ENV

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://173944]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2020-02-28 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (124 votes). Check out past polls.

    Notices?