10.07.2015 Views

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 1 ■ THE CGI MODULE 13When the code is saved <strong>to</strong> a web server and viewed through a browser, it should look likeFigure 1-3. It looks like a regular form, but don’t bother filling in the name and clicking on submityet. There’s no code <strong>to</strong> handle it!Figure 1-3. A form created with CGI module functionsViewing the source code for the resulting HTML page reveals what this bit of <strong>Perl</strong> code didin the background:HelloEnter your name: As you can see, the start_form() function inserted a tag in<strong>to</strong> the page. It au<strong>to</strong>maticallymade the method a POST and set the action <strong>to</strong> itself—"/cgi-bin/name.cgi", in this case. Youcould change both of these parameters by providing them within the call <strong>to</strong> the start_form()function, as in this example:start_form(-method=>'GET',-action=>"/cgi-bin/someothercgi.cgi")The code would then produce a form tag like this:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!