in reply to Can't set cookie with CGI.pm

the script dies when it tries setting the cookie.

Please elaborate. In what way does it die? I tried it here and it works fine.

Update: ikegami's suggestion below is correct if you are under mod_perl. I had a different problem when I tried to run the script from my personal home directory which turned out to be an Apache suexec error due to file permissions. chmod g-w filename.pl fixed it in that particular situation.

Update 2: sorry I didn't read the part where it was working without the die. See below.