Quick Table of Contents
- Declaring a new hash
- Adding a element
- Iterating through a hash
Perl: Hash variables
1. Declaring a new hash
my %desc;This let perl know that you plan on using a hash with the name desc
2. Adding a element
$desc{"key1"} = "data for key 1";Adds the value "data for key 1" into the hash desc, with a key "key1".
3. 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";
}