Tags
array, associative array, editor, env, environment variable, hash, perl, scripting, shell, shell variable, variable
The environmental variables are stored in %ENV hash (“associative array”). Now if you want to access a shell variable, say $HOME, in your Perl script, then you need to refer to it as $ENV{'HOME'}:
#!/usr/bin/perl
$my_home_dir = "$ENV{'HOME'}" ;
$my_shell = "$ENV{'SHELL'}" ;
$my_editor = "$ENV{'EDITOR'}" ;
Don’t forget the curly braces and the single quotes!
Reference: Devdaily blog.