freebie:~ 619> perl -e '$ENV{FOO} = "Really?"; system( q/bash -c "echo + $FOO"/ )' Really?

As I said, it affects the current process and any children spawned after the modification.

Update: Rather than descend another level I'll reply here.

My point is that modifications to %ENV are no more or less "persistent" than any other modification to a process' environment. Any modifications to the environment made in a shell startup file uses the same mechanism (mucking with the process' extern char **environ) and has the same scope (that process and its children); it's only by convention that they have a wider reach because they take effect further up the process tree.

If you had an account which had one of the perl shells as its login shell (or even just a perl program for that matter) modifications to %ENV from whatever startup code it ran would be just as persistent and of the same scope as those made by zsh/bash/ksh/csh/... . Saying that the modifications to environ made by one process aren't persistent has as much meaning as saying that arguments passed to system() aren't persistent, as they're ephermal and specific to a particular process.

And also note I'm speaking strictly in the POSIX-y OS sense; Wintendo does have a seperate mechanism where per-user and per-system environment settings can be made which are applied to all relevant processes.


In reply to Re^4: setting ENV variables by Fletch
in thread setting ENV variables by vikee

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.