in reply to Setting Global Variable in Sub

Most monks are going to tell you that global vars are "Bad", and this is true in almost every case.

There are answers above that tell you why, but neither of them really give an alternative.(Molt was answering at the same time as I) I would suggest returning the data from the function like:
use strict; use CGI; use DBI; my ($COOKIE_ID, $COOKIE_NAME) = &Set_Cookie_Values(); my ($CGI, $DBH) ; sub SetCookieValues { my $id = "this is the cookie id" ; my $name = "this is the cookie name" ; return $id, $name ; }

This way your vars are still scoped (although you still have a bunch in main but that is a different question :) and you are getting exactly what you need.

"Nothing is sure but death and taxes" I say combine the two and its death to all taxes!