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;