Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: validations in perl

by davido (Cardinal)
on Jul 17, 2019 at 14:53 UTC ( [id://11102958]=note: print w/replies, xml ) Need Help??


in reply to validations in perl

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11102958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found