Skip to Main Content
Perl for Web Site Management
book

Perl for Web Site Management

by John Callender
October 2001
Beginner content levelBeginner
528 pages
15h 20m
English
O'Reilly Media, Inc.
Content preview from Perl for Web Site Management

Using Parameterized Links

Now let’s take a look at those subroutines that are performed for the various unless-elsif blocks. The first one is the &show_links routine, which just sticks some HTML in the $content variable to display three links. When the user clicks on any of those links, the links will re-invoke the script to perform various actions:

sub show_links {
    $content = <<EndOfText;
    
<H1>Select an action:</H1>

<P><STRONG><A HREF="make_page.cgi?action=show_student_form">Make a 
student page</A><BR>
<A HREF="make_page.cgi?action=show_leader_form">Make a leader 
page</A><BR>
<A HREF="make_page.cgi?action=regenerate_site_links">Regenerate site 
links</A>
</STRONG></P>
EndOfText

Note how using CGI.pm makes it easy to mix and match POST- and GET-method invocations of the script. In this case, we’re using the GET method, creating links with parameters embedded in the URL. A question mark (?) separates the actual scriptname from the query string, which consists of name=value pairs. Using CGI.pm to retrieve the invocation parameters, our script can ignore the different mechanics involved in retrieving and decoding these parameters, as compared to how it would retrieve and decode parameters passed as part of a POST-method HTML form submission.

Tip

If you have multiple parameters to embed in a GET -method CGI script invocation, you use an ampersand to separate each pair. If you need to include characters that aren’t legal in a URL, you need to URL-escape them, replacing a space character ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Web Client Programming with Perl

Web Client Programming with Perl

Clinton Wong
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

Ken Williams, Dave Rolsky

Publisher Resources

ISBN: 1565926471Catalog PageErrata