well if your using cgi-lib (ie: this is in the top of your script: use CGI qw(:cgi-lib);) then you can use the nice prebuilt cookie functions:
to set a cookie (this has to happen before the content type line i believe):
$cookie = cookie(-name=> "cookiename", -value=> $FORM{user},);
print header(-cookie=>$cookie);
to read a cookie:
$cookie = cookie("cookiename");
you can set the value as an array too, so it can store a lot of data:
$cookie = cookie(-name=> "cookiename", -value=> [$FORM{user}, $FORM{pass}],);
print header(-cookie=>$cookie);
then read it like this:
@cookie = cookie("cookiename");
$user = $cookie[0];
$pass = $cookie[1];