If cookies are enabled in your browser, the following should set a cookie named 'cookThis' and with each hit of this code, the value of the cookie should swap back and forth between null and 'Some Cookie value here'.
#!/usr/local/bin/perl
use CGI;
$query = new CGI;
$thisCGI = $query->url();
# try to read the cookie via the CGI.pm method
$cookThis = $query->cookie(-name=>'cookThis');
# If the cookie exists, edit it's values.
# else, create it's values.
if ($cookThis)
{
$cookie = $query->cookie(-name=>"cookThis",
-value=>'',
-expires=>"+1h"

;
}
else
{
$cookie = $query->cookie(-name=>"cookThis",
-value=>"Some Cookie value here",
-expires=>"+1h"

;
}
# print the cookie in the header.
print $query->header(-cookie=>$cookie);
print "<BR>CookThis is $cookThis<BR>";
print $query->start_html(-title=>"cook this"

;
print $query ->start_multipart_form('POST',"$thisCGI"

;
print '<BR>',$query->submit('doWhat','cook');
print $query->end_form;
print $query->end_html;
Just ask if you have questions....
HTH
keep the rudder amid ship and beware the odd typo