Store color value in a hash : Hash Value « Hash « Perl






Store color value in a hash

    

#!/usr/bin/perl -w       

use strict;

my %colors = (
   red    => '#FF0000',
   green  => '#00FF00',
   blue   => '#0000FF',   
   white  => '#FFFFFF',      
   black  => '#000000',
   purple => '#520063'
);

print "Red is:    $colors{red}\n";
print "Blue is:   $colors{blue}\n";
print "Purple is: $colors{purple}\n";

   
    
    
    
  








Related examples in the same category

1.Associative arrays are indexed by string values.
2.Building a Price List
3.Using array as the hash value
4.Using the array as the hash value
5.Hash setting and getting
6.Accessing Elements
7.Adding elements to a hash