You might not store password in plain-text anymore, however your cookie should be implemented the same way.
Comparing md5_dbpass to md5_hashpass. Or better yet learn how to use sessions. I don't know why you code in perl and cgi. I would transition to php and code plugins and add-ons for punbb (fluxbb).