New! Try the new FileUpload module too. NAME CGI_LIB -- This is a perl module which will help you to manipulate the CGI input. SYNOPSIS use CGI_LIB; $obj = new CGI_LIB(); EXAMPLE Form Processing (application/x-www-form-urlencoded) http://www.tneoh.zoneit.com/perl/CGI_LIB/form_urlenc.html CGI Script Used In Form Processing (application/x-www-form-urlencoded) http://www.tneoh.zoneit.com/perl/CGI_LIB/testCGI_LIB.pl Form Processing (multipart/form-data) HTTP File Upload http://www.tneoh.zoneit.com/perl/CGI_LIB/form_multipart.html CGI Script Used In Form Processing (multipart/form-data) HTTP File Upload http://www.tneoh.zoneit.com/perl/CGI_LIB/uploader.pl Simple Perl CGI Script To Save Uploaded File http://www.tneoh.zoneit.com/perl/CGI_LIB/simple_uploader.pl Receive The File That You Upload? New!! http://www.tneoh.zoneit.com/perl/SendMail/2.0/form.html DESCRIPTION This is a modification from CGI_LIB.pl. CGI_LIB.pm module does not have complicated/powerful functions that CGI.pm have. It just a simple module which helps you to process the CGI input, i.e. the submitted form data. Of course, it supports HTTP File Upload. For a NT user, bimode(FILEHANDLE) is needed after the FILEHANDLE is created when we try to save a binary uploaded file, like .gif and .jpg files. When you create the CGI_LIB object by using "new CGI_LIB()", the module will automatically process the data according to the form method used ( "GET" or "POST" ) and the "Content-Type" of the submitted data ( "application/x-www-form-urlencoded" or "multipart/form-data" ). And the module will set the data into the object. Getting Data From The CGI_LIB Object: $obj->{'field_name'}, where "field_name" is the name that you set insides the "input" HTML tag. There are three types of variables that you will get from the CGI_LIB object. Single Value : Contains only one value. eg. <input type="text" name="emailaddress" size="40"> If the user key in "userid@domain.com" into this text box, $obj->{'emailaddress'} will give you "userid@domain.com". Array Reference : Contains multiple values, like multiple "select"ion and "checkbox". eg. <input type="checkbox" name="hobby" value="0">Computer <input type="checkbox" name="hobby" value="1">Reading <input type="checkbox" name="hobby" value="2">Travelling If the user checks all the three checkboxes, $obj->{'hobby'} will contains the reference of an array. @{$obj->{'hobby'}} will contains "0", "1" and "2". ref($obj->{'hobby'}) will return "ARRAY". Hash Array Reference : Basically, this variable will contain the uploaded file's information. It consists of the following fields: name : The name used in the "input" HTML tag. filename : The uploaded file's name. content-type : The "Content-Type" of the uploaded file. contents : The content of the uploaded file. size : The size of the uploaded file. eg. <input type="file" name="afile"> If the user select a file, C:/test.txt, and contains "This is a test file.". $obj->{'afile'}->{'name'} = "afile" $obj->{'afile'}->{'filename'} = "C:/TEST.TXT" $obj->{'afile'}->{'content-type'} = "text/plain" $obj->{'afile'}->{'contents'} = "This is a test file." $obj->{'afile'}->{'size'} = 20 ref($obj->{'afile'}) will return "HASH". Errors, comments or questions are welcome. CHANGES 1.00->1.01 CGI_LIB.pm doesn't process the data that is passed as QUERY_STRING. AUTHOR Simon Tneoh Chee-Boon tneohcb@pc.jaring.my Copyright (c) 1998,1999 Simon Tneoh Chee-Boon. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SOURCE http://www.tneoh.zoneit.com/perl/CGI_LIB/CGI_LIB.pm VERSION Version 1.01 21 August 1999