Saving Windows Environment Keys for Perl Windows UPCASES

I have a framework written in Perl that sets up a bunch of environment variables to support inter-process communication (usually a subprocess). We store a set of key / value pairs in XML-ish files. We tried to make the key names of the camel case somethingLikeThis. It all works well.

We recently had to go through control (chaining) processes from Windows to UNIX. When we push the hash %ENVinto a file from Windows, the key somethingLikeThisbecomes somethingLikeThis. When a Unix process picks up a file and reloads the environment and looks at the value $ENV{somethingLikeThis}, it does not exist, since UNIX is case sensitive (on Windows, the same code works fine).

We have since returned and changed all the keys to UPPERCASE and solved the problem, but it was tiring and caused pain for users. Is there a way to force Perl to save the environment hash key character symbol on Windows?

+3
source share
5 answers

I believe that you will find that Windows environment variables are actually case insensitive, so the keys are uppercase to avoid confusion. Thus, Windows scripts that do not have a case-sensitive understanding can use the same variables as everyone else.

+3
source

, ALL_CAPS Windows, * NIX-. , Perl - API- , , .

, - , , , , ? , , , , ...

+2

-, , , . Windows script .

my %env = map {/(.*?)=(.*)/;} `set`;
print join(' ', sort keys %env);

25: " Perl" " " " , % ENV, , - % ENV . Unix , ".

+2

.: , Windows. Foo, Perl $ENV {FOO} $ENV {fOO} $ENV {foo}. : Foo % ENV , * NX script $ENV {Foo}, - ( $ENV {FOO}).

UPPERCASE, . , " " % ENV Perl Windows.

0

As far as I know, this is not happening. It seems you might be better off using a different hash instead of% ENV. If you call many external modules and want to track the same variables on them, the Factory template can work so that you do not violate DRY and can use a case-sensitive hash code on several modules. The only trick would be to keep these variables updated across all objects from Factory, but I'm sure you can solve this.

0
source

Source: https://habr.com/ru/post/1696649/


All Articles