Declaring a new hash
my %desc;
This lets perl know that you plan on using a hash with the name desc
.
Adding an element
$desc{"key1"} = "data for key 1"
Adds the value data for key 1
into the hash desc, with a key key1
.
Iterating through a hash
Environment variables are passed to perl via the ENV hash. The example below lists all environment variables
foreach $key (sort keys %ENV) {
print "$key = $ENV{$key}\n";
}