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 &
(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 |