Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Do not use DreamWeaver. Do not use DreamWeaver. That way might seem easier, but down that path you will find pain and suffering, because the HTML that you get out of DreamWeaver will be very hard to break into manageable pieces and integrate with the logic in your Perl script.

You can teach yourself enough HTML to get this done in about an hour using information that is available on the web. This is not very much more time than it would take to learn DreamWeaver, and the resulting HTML will be *MUCH* easier to work with and to integrate into your Perl code. HTML is very easy to learn, and will take much less time and effort than you spent learning Perl, to say nothing of Java or C++. An intelligent person with a natural bent toward computers can master HTML in a long weekend, and you don't need to master it; you just need to learn the basics.

Yes, CGI is the way to go for this. You will use a form element in your HTML, which will contain the various inputs, including a submit button. The action attribute of the form element will point to your Perl script. There are various CGI-related modules on the CPAN (see search.cpan.org), which you can use to get the form input. Some of them (for instance, CGI.pm) have complex interfaces for things like generating HTML, but you can safely ignore all of that. The only thing you need them for is to collect the form input. For generating the HTML, it's much easier to just learn HTML and use print statements (maybe with heredocs and/or the qq[somestring] quoting mechanism, since the strings you are printing will often contain quotation marks).

As far as sending the results back to the browser, the most important thing to know is that you have to print out the HTTP headers first, then a blank line, then whatever HTML you want to send. The only HTTP header that is mandatory is the Content-type header, which will look probably like this: Content-type: text/html\n

Enjoy this assignment. You've waited to the last second, but nonetheless writing CGI scripts is one of the easier and more pleasant programming assignments you could be given. Once you've written one of them, it becomes easy to whip together another one real quick sometime later. Before you know it you'll be doing your layouts with stylesheets, scripting events with Javascript, manipulating page elements via the DOM, and loading in parts of pages dynamically with XMLHttpRequest. But for now, just do the basic CGI script.


In reply to Re: PERL and HTML by jonadab
in thread PERL and HTML by vashbrowns

Title:
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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found