Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
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 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.


"To be civilized is to deny one's nature."

In reply to Re: Re (tilly) 2: for HTML output? by shotgunefx
in thread for HTML output? by jrsmith

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.