Wednesday, December 22, 2010

Hash/ Associative arrays in Perl

Hash/ Associative arrays in Perl are also responsible for storing multiple 
elements together in one variable, as a key value pair.

#!/usr/bin/perl

print "content-type: text/html \n\n"; 

%country_capital_hash=(
'india' => 'New Delhi',
'china' => 'beiging'
);

print "Capital of India is $country_capital_hash{'india'}\n";

Output:
-------
Capital of India is New Delhi