Although it may work brilliant minds in the Perl community such as Lincoln Stein and Randall Schwartz spent a significant amount of their career in the late 90s hunting down all the edge cases you're probably unaware of and produced CGI.pm. You can still learn a lot about CGI from this module but your exposure to vulns will be that much lower with something tried and tested.