On systems (shells rather) where there is a distinction between the case-sensitivity of Env. Vars, %ENV behaves rather normally like a hash should.$ set comspec ComSpec=C:\WINDOWS\system32\cmd.exe $ echo %comspec% C:\WINDOWS\system32\cmd.exe $ echo %COMSPEC% C:\WINDOWS\system32\cmd.exe $ perl -le "print 'comspec : ', $ENV{comspec}" comspec : C:\WINDOWS\system32\cmd.exe $ perl -le "print 'COMSPEC : ', $ENV{COMSPEC}" COMSPEC : C:\WINDOWS\system32\cmd.exe
It's likely %ENV is tied (I am guessing) or has mechanism similar to tie associated with it to pass lookups to an underlying system call. It should be noted that not all environmental varaibles are populated into %ENV and in other cases, the values of %ENV contradict those of the shell (as shown above). Don't rely too heavily on information or its validity presented to you in %ENV;$ set | grep -i ^shell shell /bin/tcsh $ echo $shell /bin/tcsh $ echo $SHELL $ perl -le 'print "shell : ", $ENV{shell}' shell : $ perl -le 'print "SHELL : ", $ENV{SHELL}' SHELL : /bin/bash
For the purposes of delayed expansion in the environment, Win32::ExpandEnvironmentStrings() then takes a literal string of the form !Foo! rather than %Foo%.$ set var var=%OS% $ perl -MWin32 -e "print $ENV{var} .= ' evaled' , ' => ', Win32::Expa +ndEnvironmentStrings($ENV{var})" %OS% evaled => Windows_NT evaled
$ set var=Foo $ set var var=Foo $ set var=Bar & perl -MWin32 -e "print Win32::ExpandEnvironmentStrings +('%var%')" Foo $ set var var=Bar $ set var=Baz & perl -MWin32 -e "print Win32::ExpandEnvironmentStrings +('!var!')" Baz $ set var var=Baz
In reply to Re^3: Win32 GetEnvironmentVariables?
by Firefly258
in thread Win32 GetEnvironmentVariables?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |