Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Persistent environment (Windows)

by Rudif (Hermit)
on Apr 10, 2001 at 02:47 UTC ( #71196=note: print w/replies, xml ) Need Help??

in reply to Persistent environment (Windows)

Is there a way to force calls to system() to use the same environment as the main Perl program?

I am confused. To me, your test shows that the calls to system() inherit the environment from the main Perl program, but that changes made to the environment inside the system() call do not propagate back into the Perl program's environment.

Dave Roth's book Win32 Perl Scripting, Chapter 6, has a section on 'Modifying the User Environment', which might be worth a glance. He shows how to set permanently e.g. $ENV{'MonkeyLikes'}, using his module Win32::AdminMisc - close, but different from what you want to do.


PS. By an amazing coincidence, the Chapter 6 of Dave's book is available online at the above URL as a sample chapter.

Replies are listed 'Best First'.
Re: Re: Persistent environment (Windows)
by idnopheq (Chaplain) on Apr 10, 2001 at 16:49 UTC
    This is correct. The line
    system("set monkeylikes=flinging poo");
    sets %monkeylikes% for that system call only. You would need Win32::AdminMisc to set the variable permanently, or do
    $ENV{'MonkeyLikes'} = "bananas"; print "$ENV{'MonkeyLikes'}\n"; system("echo %monkeylikes%"); $ENV{'MonkeyLikes'} = "flinging poo"; system("echo %monkeylikes%");
    for on-the-fly while-the-script-executes kind-of stuff. It yields

    flinging poo

    I believe from the parent post that this is what you are looking for, but that is just my opinion. I could be wrong.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-08-16 22:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found