Perl Monk, Perl Meditation | |
PerlMonks |
Re: validations in perlby davido (Cardinal) |
on Jul 17, 2019 at 14:53 UTC ( [id://11102958]=note: print w/replies, xml ) | Need Help?? |
There is a tendency when people develop CGI scripts to toss all the business logic (the model), all the support logic (such as validation), all the rendering code (the printing, the HTML generation, the view) into the same ball of mud with the CGI handling (params, dispatch handling, the application controller). The result is a hard to test mess. This code is going down that path, and you're experiencing the pain it can cause. Break your validation out into a separate testable module. Separate out your rendering. Divorce the business logic from the CGI handlers. You'll find that by doing so you'll be able to leverage the good parts of Perl, like its rich set of testing tools. When you write tests against your validation code, you'll better understand why the validation is failing to do what you want. Have a look at the book Intermediate Perl for a good discussion on modules and testing. Dave
In Section
Seekers of Perl Wisdom
|
|