$cookie = join "\0", %hash; $cookie =~ s/(\W)/'%'.sprintf("%02lx",ord($1))/ge; #... print cookie ... #read cookie back to hash... $cookie =~ s/%([a-fA-F\d][a-fA-F\d])/chr(hex($1))/ge; %hash = split "\0", $cookie;