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

Hello, I'm coverting VBA script to Perl. Could any one tell me the eqvivalent perl code of the below mentioned VBA script: Private Declare Function SetEnvironmentVariable Lib _ "kernel32.dll" Alias "SetEnvironmentVariableA" (ByVal _ lpName As String, ByVal lpValue As String) As Long many thanks in advance! Regards, Prashanth

Replies are listed 'Best First'.
Re: Set Environment Variable
by cdarke (Prior) on Feb 16, 2011 at 09:07 UTC
    $ENV{Name} = Value;If you really wanted to you could call the Win32API SetEnvironmentVariableA but there would be no advantage in doing so (and a lot of pain).

    Note that Environment variables names are not case sensitive on Windows, but on UNIX/Linux they are. Changing an environment variable will not alter the setting in the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and HKEY_CURRENT_USER\Environment) and will only affect child processes of the current Perl program. This is the same effect as SetEnvironmentVariableA.
Re: Set Environment Variable
by moritz (Cardinal) on Feb 16, 2011 at 08:46 UTC