#!perl
use CGI qw( :standard );
print header, start_html( "Read cookies" );
print "The folowing data is saved in a cookie on your ";
print "computer.
";
%cookies = readCookies();
print "";
foreach $cookieName ( "Name", "Height", "Color" )
{
print "";
print " $cookieName ";
print " $cookies{ $cookieName } ";
print " ";
}
print "
";
print end_html;
sub readCookies
{
@cookieArray = split( "; ", $ENV{ 'HTTP_COOKIE' } );
foreach ( @cookieArray )
{
( $cookieName, $cookieValue ) = split ( "=", $_ );
$cookieHash{ $cookieName } = $cookieValue;
}
return %cookieHash;
}