Get and Set Environment Variable

In Perl, environment variables for the OS are stored in “%ENV” hash. So, for example, environment variable “PATH” can be gotten like this.

my $path = $ENV{"PATH"};

Setting environment variable is also easy. You can just add an element to %ENV.

$ENV{"PATH"} = $path;

 

Leave a Reply

Required fields are marked *.


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Top