Skip to Content
CGI Programming on the World Wide Web
book

CGI Programming on the World Wide Web

by Shishir Gundavaram
March 1996
Intermediate to advanced
450 pages
10h
English
O'Reilly Media, Inc.
Content preview from CGI Programming on the World Wide Web

D. CGI Lite

CGI Lite is a Perl 5 library that will decode both URL-encoded and multipart form data produced by the file upload feature present in Netscape 2.0. This module does not have all of the features of the CGI::* modules, but is lightweight and slightly easier to use. Here is a simple example that outputs all the form data:

#!/usr/local/bin/perl5
use CGI_Lite;
$cgi = new CGI_Lite ();
$cgi->parse_form_data ();

print “Content-type: text/plain", “\n\n";
$cgi->print_form_data ();

exit (0);

The parse_form_data method parses the form data and stores it in an internal associative array, which can be printed out by calling the print_form_data method. Or, you can place the form data in a variable of your choice:

#!/usr/local/bin/perl5
use CGI_Lite;

$cgi = new CGI_Lite ();
%data = $cgi->parse_form_data ();

print “Content-type: text/plain", “\n\n";

foreach $key (keys %data) {
    print $key, “ = “, $data{$key}, “\n";
}

exit (0);

D.1 Multipart Forms

The file upload feature of Netscape 2.0 allows you to do just that: send files as part of a form through the network. Here is how to create a multipart form:

<HTML> <HEAD><TITLE>CGI Lite Test</TITLE></HEAD> <BODY> <H1>CGI Lite Test</H1> <HR> <FORM ACTION="/cgi-bin/upload.pl” ENCTYPE="multipart/form-data” METHOD="POST"> What is your name? <INPUT TYPE="text” NAME="username"> <P> Select a <B>TEXT</B> file to send: <INPUT TYPE="file” NAME="input_file"> <P> <INPUT TYPE="submit” VALUE="Send the Multipart Form"> <INPUT TYPE="reset” VALUE="Clear ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Sams Teach Yourself CGI in 24 Hours, Second Edition

Sams Teach Yourself CGI in 24 Hours, Second Edition

Rafe Colburn
Single Page Web Applications

Single Page Web Applications

Josh Powell, Michael Mikowski
Storage Area Networks For Dummies®

Storage Area Networks For Dummies®

Christopher Poelker, Alex Nikitin
How to Develop a Great Digital Strategy

How to Develop a Great Digital Strategy

Jeanne W. Ross, Cynthia M. Beath, Ina M. Sebastian

Publisher Resources

ISBN: 9781565921689