#!/usr/bin/perl -wT
use CGI':standard';
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
print header();
print start_html(-title => "Hashes");
my %data;
%data = ('state' => 'Arizona', 'city' => 'Kingman', population => '28000', county => 'Mohave');
print "<div style='color:#0000cc;font-size:1.1em;'>";
#printing data from a hash
print "The city of $data{'city'}, $data{'state'}, is located in $data{'county'} county.<br>";
#changing data in a hash
$data{'city'} = "Lahaina";
$data{'county'} = "Maui";
$data{'state'} = "Hawai'i";
print "The city of $data{'city'}, $data{'state'}, is located in $data{'county'} county.<br>";
print "</div>";
print end_html();
Hashes
The city of Kingman, Arizona, is located in Mohave county.
The city of Lahaina, Hawai'i, is located in Maui county.