in reply to Another cookie setting question

In the second snippet you're using the 'object-oriented form' of CGI.pm. So you need to use:
my ($to_set) = $cgi->cookie(...); # and later print $cgi->header(...);
See the docs . Look at the bottom of the section 'HTTP Cookies'.

Update: Pointed the link to HTTP COOKIES.