Here's an approach: add a query string to your url that specifies which page to display. Something like:   http://my.server.com/multipage.pl?page=1 Then, in your perl script, you grab this value and use it to decide which page to display. The query string can be anything you want: "?display=CoolStuff" would work fine. Just make sure you don't include any spaces. (There's a way to do that but don't worry about it now.)

Two ways to get the query string value. You can get the whole query string with    my $qstr = $ENV{QUERY_STRING}; and then parse it yourself to get the page reference.

Better would be to

use CGI my $cgi = CGI::new() or die "Can't load new CGI"; my $page = $cgi->param('page');
Then, as before, branch to or select the routine to print the specific page. You can use heredocs or normal print statements, or a mixed combination of the two, whatever does the job.

In printing your various HTML pages, you can then include the <a....> links you need with the appropriate query strings for the other pages. Like this:    <a href="http://my.server.com/multipage.pl?page=2">Show page 2</a> You can also have subroutines to spit out portions of the HTML if you have repeated sections. And you can use conditionals to deliver pieces depending on whatever you want (username, requested page, etc.)

If you want more query string values in one url in order to do cool things, just separate them with '&'. Update: Which of course, you must write as &amp; (see next post -- thanks merlin).

I recommend you check out the CGI module. You may not feel you need it for this simple exercise, but this project would be a good way to get to know it for later. It is a powerful, versatile, and well-tested module.

Also, if you want to know more about what is being passed from your browser and is capturable by Perl, here is a page that may help you.

There is also some magic involving HTTP (not HTML) headers that you need to take care of. The CGI module can help with this. Or, at the very least, just be sure to    print "Content-type: text/html\n\n"; before anything else. (Note the double NewLine.)

If you need more than this to get you going, just re-post. Good luck.

dv


In reply to Re: HTML printing by dvergin
in thread HTML printing by Quinn1981

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.