return to first page linux journal archive
keywordscontents

Listing 3. Modified CGI File

#!/usr/bin/perl -w
use strict;
no strict "refs";
use diagnostics;
use CGI;
#
# Create a new instance of CGI
my $query = new CGI;
#
# Send an appropriate MIME header to the user
print $query->header("text/html");
#
# Get the filename from the form
my $userfile = $query->param("userfile");
#
# Print a short message to the user
print $query->start_html(-title => "Your file");
print "<P>Here is the file that you uploaded:</P>\n";
print "<HR>\n";
my %headers = %{$query->uploadInfo($userfile)};
my $header = "";
foreach $header (sort keys %headers)
	{
	print "<P>$header =
\"$headers{$header}\"</P>\n";
	}
print "<HR>\n";
#
# Iterate through $userfile
while (<$userfile>)
	{
	print;
	}
#
# Finish the HTML
print $query->end_html;