Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: setting ENV variables

by pbeckingham (Parson)
on Jun 22, 2004 at 14:47 UTC ( [id://368740]=note: print w/replies, xml ) Need Help??


in reply to Re^2: setting ENV variables
in thread setting ENV variables

What are you saying 'Erm, no' to?

The %ENV hash is modifiable, it won't be reflected outside the program, and is in no way permanent.

Replies are listed 'Best First'.
Re^4: setting ENV variables
by Fletch (Bishop) on Jun 22, 2004 at 14:51 UTC
    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.

      I'm not disagreeing with you. You're just not seeing the word 'persist' in my message.

      I was trying to convey that you can make a runtime change to the environment, but not a permanent one, using %ENV.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://368740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-28 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found