Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re (tilly) 2: CGI.pm for HTML output?

by tilly (Archbishop)
on Mar 09, 2002 at 03:18 UTC ( [id://150488]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI.pm for HTML output?
in thread CGI.pm for HTML output?

Um, the split doesn't seem to be very much 50/50 from what I see.

I am not sure that I have ever met a good Perl programmer who seriously advocated using the HTML methods for producing a complex website. For small tools, one-off scripts and the like, sure. But it doesn't scale as an approach.

Replies are listed 'Best First'.
Re: Re (tilly) 2: CGI.pm for HTML output?
by shotgunefx (Parson) on Mar 09, 2002 at 16:12 UTC
    While for general purposes I would agree, but I do consider myself I good (not great) perl programmer and I've found one really nice use.

    We have our own persitance module at work based on CGI. Hopefully it will get released to CPAN eventually. It's used for heavy weight applications. Some of them have 30 different screens. We use the HTML shortcuts because by doing so, the module always knows exactly what next states are possible and what fields should be coming in, what values they are allowed to contain and depending on what type of fields (<select>s for instance) what values they can have and how many. It also handles the filefields. You can upload a file input and ten screens later still access them as though they were in the current submission.

    All of this is moved to the module layer. You dont' have to do any of the validation at all. It's all done for you.
    print "INT -100 < 31 ",textfield(-name=>'int',-validate=>{ -datatype=>'INT', -min=>'-100', -max=>'31', -required=>1 } ),br();

    Now when the user submits, the module knows that it needs a a parameter called int with a value between -100 and 31. If it doesn't get it, it rolls back to the previous screen with an error message "You need to enter an integer between -100 and 31" automatically generated and the offending field marked visually.

    Of course, generating the actually code for a complex layout is a huge pain which is why we have a custom parser that takes an HTML page and translates it to CGI.pm syntax. Now this type of solutions isn't for everything. (Lot's of overhead) but for a complex app it certainly can outweigh the cons.

    For a simple app, this would be like lighting a cigarette with a blowtorch but unifying the input and output does offer some interesting possiblities.
    My two cents anyway.

    -Lee

    "To be civilized is to deny one's nature."
      I wasn't ragging on CGI's html methods because they don't work in some way. I was down on them because separating content and presentation happens to be a very good bargain. Writing CGI's html methods to produce desired output is a bad code factoring.

      And it sounds like your company realized the same thing. Yes, you use CGI's html methods. But you don't code them up. Instead you autogenerate it from regular HTML. (And presumably you could take the original, put it through standard design tools, and then re-autogenerate the CGI code. If you can't then take the energy to figure out how to make that doable. You will make up for the effort in savings on maintainance.)

      That works. That addresses the objection squarely.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 13:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found