http://www.perlmonks.org?node_id=13136
Category: file convertor
Author/Contact Info BigJoe email: big_joe1008@linuxstart.com
Description: This is a script that I put together for use on my source code page. This script then allows me to copy html and scripts into a dir and let people pick the ones they want to view and I don't have to set up a page for each. It does require a param sent to it by using ?html=filename.
Update 6/2/200 With the help of Fastolfe I have added some testing on the $in{html} to make sure it is not tainted.
#!/usr/bin/perl -w

require "../../cgi-lib.pl";

ReadParse(*in);

$openbr="<";
$closebr="&rt;";
# $listing=`./allhtml.pl`;  #this script outputs a list of all my html
              #files.
if($in{html){
if ($in{html} =~ /^([-\@\w.]+)$/) {
        $filename = $1;                
} else {
        die "Bad data in $in{html}";         
}    

open(LINKPAGE, $filename);
    $filesize = -s LINKPAGE;
    read(LINKPAGE, $wholepage, $filesize);

$wholepage=~s/</$openbr/g;
$wholepage=~s/>/$closebr/g;

print "Content-type: text/html\n\n";
print "<HTML><BODY><PRE>";
print "<FONT size = 5><Center>";
print $in{html};
print  "</Center></FONT><BR>";
print "$wholepage <BR><BR>";
}
print $listing;
print "<!--Written by Joseph Harnish--><A
HREF=\"http://www.csis.gvsu.edu/~harnisjl\">Big Joe
</A></PRE><BR><BR><BR>\n\n
<FORM NAME=\"myForm\" ACTION=\"html2code.pl\" METHOD=\"POST\">
<TABLE CELLPADDING=2 CELLSPACING=0>
<TR><TD WIDTH=50>File name:</TD><TD><INPUT TYPE=TEXT NAME=\"html\"
SIZE=\"30\"></TD></TR>
</TD>
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT VALUE=\"View\"></TD></TR>
</TABLE>
</FORM>
</BODY></HTML>";

close(LINKPAGE);

exit;