If you're talking about "environment variables" in the sense of "shell environment variables", which are provided to perl scripts via the "%ENV" global hash, then I'm curious why the order in which variables are defined should make any difference. As I understand it, environment variables are treated (by Perl and shells) as an unordered set of "name,value" pairs -- that's why ENV is a hash in Perl.

To the extent that certain variables define "search paths", the ordering of elements within the value of such a variable is of course very important. So I could imagine a process, for example, that will come up with two or more distinct elements to be appended to the value of a variable named "PATH", and the order in which these elements are appended can make the difference between success and failure.

But why would it be important (for example) to make sure that you assign a value to "PATH" before (or after) you assign a value to some other variable? Just curious...

(update: reworded last paragraph)

Another update: On second thought, I realize that people often design and implement shell environments by using dependencies among variables -- e.g. "FOO=baz; BAR=$FOO.bar" and so on. But I'm having trouble imagining any other situations where ordering of variable definitions is an issue, and in this case, assigning numeric priorities to the assignments would not seem like the best approach. It would be better for the organization of the hash to represent the dependencies directly.


In reply to Re: a hash with priority by graff
in thread a hash with priority by meirgold

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.