Adding an element to a hash

Simply assign a value to a hash individual element, e.g.:
$prices{"coat"} = 250;
        #coat, 250 will be added to the %prices hash

Deleting an element from a hash

use the delete function, e.g.:
delete $prices{"coat"};

Checking whether a hash is empty

if (%hash_name) {      # will be false if hash is empty

Using a Hash for Counting


Using a Hash for Eliminating Duplicates

 $genbank{$accession} = 1;
In this case, the keys in the hash are what's important.
The values may be irrelevant.

Table of Contents.
Previous | Next.