#get value from cookies

my %cookies;
%cookies=fetch CGI ::cookie;
my $id=$cookies{'ID'}->value if exists $cookies{'ID'};
my $pwd=$cookies{'PWD'}->value if exists $cookies{'PWD'};


#set cookies
sub cook(){
my $name=shift;
my $pass=shift;
%cookies=(ID=>new CGI ::cookie(
-name=>'ID' ,
-value=>$name ,
),
password=>new CGI::cookie(
-name=>'PWD',
-value=>'$pass'
),

);


this is my code but i can print header but i can't print value out...
Why is problem....


}