HTML isn't all that mysterious, it's just plain text laced with tags that are also based on plain text. For example, <a href = "somelink"> text </a> is all based on simple text. For a script to output HTML, it just needs to print. If you want to output the above HTML, you would do this:

print '<a href = "somelink"> text </a>', "\n";

If you're parsing CGI input (GET and POST data), that's often done using CGI. The same module also provides helper functions for generating HTML code, though for lightweight solutions I prefer just printing it, and for heavy-weight solutions, a templating system is probably better. Tools like HTML::Mason allow you to easily separate the content and HTML from the script's code, which usually improves maintainability and reduces development time for more complex dynamic websites.

As for querying from a database, the Perlish way is to use the DBI module, along with the appropriate DBD (database driver) module. To be more specific, we would need to know what database you're querying and what you wish to query from the DB.

Logins can be handled a number of ways. There's simple .htaccess provided by the webserver, and more elaborate schemes as well. It's all dependant on what you want and need. Session management is often handled by CGI::Session and its companion modules.

Another approach to CGI programming is through CGI::Application. This module is intended to be subclassed, as the building blocks to your own object-oriented CGI application.

Pagination is simply a matter of keeping track of how much content you plan to output, and deciding how much of that content you wish to put on a given page. There's not much to say there. If you've got content of 10000 characters, maybe you would want to divide the content into pages of 2000 characters instead. If that's a challenge, you've got some reading to do before you should even be considering handling things like website logins and database queries. Learning Perl, published by O'Reilly & Associates (the Llama book) is a great place to start for learning about Perl.

For CGI strategies and discussion, I happen to like the Mouse book, CGI Programming with Perl, Second Edition, also published by O'Reilly & Associates. If dealing with CGI is kind of new to you, the book will really be helpful. Not that CGI is terribly complex, but until you've gotten the big picture, it's easy to stab away in the dark never quite hitting the mark.

I hope this helps to point you in the right direction.


Dave


In reply to Re: how to generate html with perl and design pagination without query database by davido
in thread how to generate html with perl and design pagination without query database by weihe

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.