- Perl Script: Read the Environment Variables

The %ENV associative array lists the environment variables defined for a program and their values. The environment variables are the array subscripts, and the values of the variables are the values of the array elements.

Source: cat env_variable.pl
#!/usr/bin/perl

$term = $ENV{"TERM"};
print "Terminal you are using: $term \n";

$desktop = $ENV{"DESKTOP_SESSION"};
print "Desktop you are using: $desktop \n";

$lang = $ENV{"LANGUAGE"};
print "Lang you are using: $lang \n";

Output: perl env_variable.pl
Terminal you are using: xterm
Desktop you are using: kde-plasma
Lang you are using: en_US:




source:http://linuxpoison.blogspot.com/2012/11/135781677516553.html