Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get All The Current Environment Variables Into An Array

Status
Not open for further replies.

milage

Programmer
Jul 13, 2001
58
US
Hi,

I need to write a script which extracts all the currently set envrionment variables into an array of the format

{ Variable_Name , Variable_Value }

Any help would be much appreciated.

Rob Miles
 
The environment variables are in the %ENV hash - do this:

foreach $key (sort keys %ENV) {
print "$key=$ENV{$key}\n";
}

HTH. Hardy Merrill
 
jamisar, sorting was something that I chose to do - it is *NOT* necessary. I copied and pasted that from something I use to display the enviroment variables in a cgi script, and the sort just happened to be in there.

HTH.

Hardy Merrill Hardy Merrill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top