1. Perl
  2. Predefined variable
  3. here

Get/set environment variable%ENV

Environment variable can be got and set by using the predefined variable "%ENV".

%ENV

This environment variable is hash with the environment variable name as the key.

For example, in the case of the environment variable "REMOTE_ADDR", you can refer to the value as follows.

my $remote_addre = $ENV{REMOTE_ADDR};

If you want to set environment variable, do as follows.

$ENV{MYAPP_MAX_CLIENT} = 10;

What are environment variable?

Environment variable are like variable that the OS has. Environment variable are copied into the memory of the process space when the OS starts the process. OS environment variable cannot be changed from the process.

Environment variable can be set freely, but they are valid only in that process. When a process launches a child process, the environment variable are copied, as if the OS launched the process.

Related Informatrion