Associative arrays are indexed by string values. : Hash Value « Hash « Perl






Associative arrays are indexed by string values.

    

#!/usr/local/bin/perl -w

my %cities = ("Toronto" => "East", "Calgary" => "Central", "Vancouver" => 'West');

for $key (keys %cities)
{
   print "Key: $key Value: $cities{$key} \n";
}

   
    
    
    
  








Related examples in the same category

1.Building a Price List
2.Using array as the hash value
3.Using the array as the hash value
4.Hash setting and getting
5.Store color value in a hash
6.Accessing Elements
7.Adding elements to a hash