# Saving Perl Windows Environment Keys UPCASES them

I have actually a structure created in Perl that establishes a number of setting variables to sustain interprocess (commonly it is sub procedure) interaction. We maintain a collections of key/value sets in XML - ish documents. We attempted to make the key names camel - instance somethingLikeThis. This all jobs well.

Lately we have actually had celebration to pass control (chain) procedures from Windows to UNIX. When we spew out the %ENV hash to a documents from Windows the somethingLikeThis key comes to be SOMETHINGLIKETHIS. When the Unix procedure grabs the documents and also refills the setting and also seeks out the value of $ENV{somethingLikeThis} it does not exist given that UNIX is instance delicate (from the Windows side the very same code functions penalty). We have actually given that returned and also transformed all the keys to UPPERCASE and also addressed the trouble, yet that bored and also created discomfort to the customers. Exists a means to make Perl on Windows maintain the personality instance of the keys of the setting hash? 3 2022-06-07 14:37:58 Source Share Answers: 5 First, to address your trouble, I think making use of backticks around set and also analyzing it on your own will certainly function. On my Windows system, this manuscript functioned simply great. my %env = map {/(.*?)=(.*)/;} set; print join(' ', sort keys %env);  In the camel publication, the suggestions in Chapter 25: Portable Perl, the System Interaction area is "Don't rely on a details setting variable existing in %ENV, and also do not think that anything in %ENV will certainly be instance delicate or instance preserving. Do not think Unix inheritance semiotics for setting variables ; on some systems, they might show up to all various other processes." 2 2022-06-25 02:12:55 Source To the most effective of my expertise, there is not. It appears that you might be far better off making use of an additional hash as opposed to %ENV. If you are calling several outdoors components and also intend to track the very same variables throughout them, a Factory pattern might function to make sure that you are not damaging DRY, and also have the ability to make use of an instance - delicate hash throughout numerous components. The only method would certainly after that be to maintain these variables upgraded throughout all things from the Factory, yet I'm certain you can function that out. 0 2022-06-08 16:02:38 Source Jack M.: Agreed, it is not a trouble on Windows. If I create a setting variable Foo I can reference it in Perl as$ENV FOO or $ENV fOO or$ENV foo . The trouble is: I create it as Foo and also unload the whole %ENV to a documents and afterwards read in the documents from * NX to recreate the Environment hash and also make use of the very same manuscript to reference $ENV Foo , that hash value does not exist (the$ENV FOO does exist).

We had actually taken on the all UPPERCASE workaround that davidg recommended. I was simply asking yourself if there was ANY means to "preserve case" when drawing up the keys to the %ENV hash from Perl on Windows.

0
2022-06-08 04:42:00
Source

I think that you'll locate the Windows setting variables are in fact instance aloof, hence the keys are capital to avoid complication. In this manner Windows manuscripts which do not have any kind of principle of instance level of sensitivity can make use of the very same variables as every little thing else.

3
2022-06-07 20:34:04
Source

As much as I bear in mind, making use of ALL_CAPS for setting variables is the advised technique in both Windows and also *NIX globes. My hunch is Perl is simply making use of some sort of heritage API to access the setting, and also hence just fetches the upper - instance - just name for the variable.

Regardless, you need to never ever rely upon something like that, a lot more so if you are asking your customers to set up the variables, simply visualize just how much worry and also complication a straightforward misspelt variable would certainly generate! You need to bear in mind that some OSes that will certainly continue to be anonymous have not still found out just how to do instance delicate documents

2
2022-06-07 16:29:30
Source