Fastolfe pretty much covered %ENV, but seemed a little unsure on the details, so I'll reiterate with a little more information. :-) (++ for Fastolfe though!)
When Perl starts up it creates the %ENV associated array, which contains all your environment variables of the calling process (usually the shell). To catch a quick glimpse of the contents, do something like this:
perl -MData::Dumper -we "print Data::Dumper->Dump([\%ENV], ['ENV']);"
Which should make things pretty clear. You can edit any of these elements as you would any hash. Whenever you create a child process (or a system call or what-have-you) Perl passes this %ENV hash to that process to use. Thus everything below you becomes effected by your changes. However, this hash is not passed UP to the calling process, only down to the children.
To make permenant changes on an MSWin32 system you need to muck with the registry. A great way to do that is Win32::TieRegistry. Do so, however, at your own risk.
Update:I just remembered that this is a FAQ!, check out "How can I change the environment from within my Perl script?." I remembered because my post seemed familliar, and then I remembered answering this in Q&A.
|