LJ Archive

Listing 2. CGI Program

#!/usr/bin/perl -w
use strict;
no strict "refs";
use diagnostics;
use CGI;   # Available from http://www.perl.com/CPAN/
#
# 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<HR>\n-;
#
# Iterate through $userfile
while (<$userfile>)
{
   print;
}
#
# Finish the HTML
print $query->end_html;
LJ Archive