Sprad has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to convert some nasty Windows batch scripts into Perl, but I ran into a problem.
I know that when I run a Perl program, it gets its own environment, so changes made to variables disappear after the program's done. That's fine, I can live with that. But I just found out by experimentation (see code) that each call to system() also gets its own environment. Bugger.
Is there a way to force calls to system() to use the same environment as the main Perl program? If possible, I'd like to do this without modules outside the main Perl install, for easier distribution to those who'll be using it.
Here's my test code. When I run it, monkeylikes is always reported to be "bananas".
--- I'm too sexy for my .sig.$ENV{'MonkeyLikes'} = "bananas"; print "$ENV{'MonkeyLikes'}\n"; system("echo %monkeylikes%"); system("set monkeylikes=flinging poo"); system("echo %monkeylikes%");
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Persistent environment (Windows)
by Rudif (Hermit) on Apr 10, 2001 at 02:47 UTC | |
by idnopheq (Chaplain) on Apr 10, 2001 at 16:49 UTC | |
(tye)Re: Persistent environment (Windows)
by tye (Sage) on Apr 10, 2001 at 01:47 UTC | |
Re: Persistent environment (Windows)
by monk2b (Pilgrim) on Apr 10, 2001 at 01:54 UTC | |
by Sprad (Hermit) on Apr 10, 2001 at 01:56 UTC |
Back to
Seekers of Perl Wisdom