|No such thing as a small change
Yes, that will cause a problem if you print it before the header. The header must come first. The cookie must be in the header. If you print anything else first and the web browser accepts the cookie, it's broken.
Your web server may add headers automatically if you don't print the headers first, but your cookie won't be set if that happens. You get one chance to print the HTTP header and the cookie must be in that header.
I'm being very explicit here because this trips up a lot of people.
As far as the domain issue, you may need to add a trailing period. I seem to recall that CGI::Cookie checks to see if the domain name contains two periods. Does it work better with example.com.?
In reply to Re: Re: Re: Problem setting cookie using CGI::Cookie