in reply to The 1st program runs, the 2nd downloads

The code you posted works all right on my computer. The only thing I could suggest you is to try outputting the header (in cookie_test.cgi) using CGI.pm:

print $q->header();

instead of doing it by hand, which should however work as well.

Michele.