Re: Using System to read mixed cased environment variables on Windows



On Jun 28, 4:00 am, Thierry <lamthie...@xxxxxxxxx> wrote:
On Windows XP Pro 32 bit, if I want to output environment variables
PYTHON or ProgramFiles, I use the set command which output the
following:

C:\set PYTHON
PYTHON=C:\Python24\python.exe
C:\set ProgramFiles
ProgramFiles=C:\Program Files

If I used Perl 5.003_07 and use the system subroutine to show the
environment variables, I get the following.  Perl script is:

system("set PYTHON");
system("set ProgramFiles");

Output is:
PYTHON=C:\Python24\python.exe
PROGRAMFILES=C:\Program Files

You'll notice that through system, the environment variable
ProgramFiles is all in upper case.  Is there a way to preserve the
mixed case of the environment variable through system(...)?

I find that case is preserved with perl 5.6.2, 5.8.8 and 5.10.0:

C:\>set MyTest=C:\MyTest

C:\>set MyTest
MyTest=C:\MyTest

C:\CVS>perl -e "system(\"set MyTest\")"
MyTest=C:\MyTest

C:\CVS>set MITEST=C:\MiTest

C:\CVS>perl -e "system(\"set MiTest\")"
MITEST=C:\MiTest

Not quite sure why you get the behaviour you reported ... perhaps it
is just that antiquated version of perl you're running. I guess you
could update your perl and see if the behaviour changes. (Though as
Ron Bergin has already indicated, there are better ways of accessing
the environment variables anyway.)

Cheers,
Rob
.



Relevant Pages

  • Re: Using System to read mixed cased environment variables on Windows
    ... On Windows XP Pro 32 bit, if I want to output environment variables ... PYTHON or ProgramFiles, I use the set command which output the ... If I used Perl 5.003_07 and use the system subroutine to show the ...
    (perl.beginners)
  • Using System to read mixed cased environment variables on Windows
    ... On Windows XP Pro 32 bit, if I want to output environment variables ... PYTHON or ProgramFiles, I use the set command which output the ... If I used Perl 5.003_07 and use the system subroutine to show the ...
    (perl.beginners)
  • Using System to read mixed cased environment variables on Windows
    ... On Windows XP Pro 32 bit, if I want to output environment variables ... PYTHON or ProgramFiles, I use the set command which output the ... If I used Perl 5.003_07 and use the system subroutine to show the ...
    (comp.lang.perl.misc)
  • Re: Environment veriable
    ... Perl should inherit whatever the environment shell it is called in. ... UNIX) concerning environment variables. ... It should unless the batch file commands prior to it span a new ...
    (perl.beginners)
  • Re: unsetenv in the shell
    ... i have a perl program that calls another application. ... application uses the value of certain environment variables during its ... system("unsetenv VAR1"); ... in a perl script. ...
    (comp.lang.perl.misc)