I'm trying to convert this script CGI.pm. Currently the script will allow a user to delete one file at a time, I would like to give the ability to delete multiple files at once. I have attempted to convert it to CGI.pm but am getting the dreaded error 500. Anyone have any suggestions? Thanks, lisaw
exit if $operate==0; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value)=split(/=/,$pair); $value =~ tr/+/ /; $value=~s/%(..)/pack("c",hex($1))/ge; $f{$name}=$value; chomp($f{$name}); } print "Content-type:text/html\n\n$head $pageadmin $mid\n"; print " <table border=0 width=100% cellspacing=0 cellpadding=1>\n"; print "<tr><td bgcolor=#CCCCCC><b>&nbsp;File Removal System</b></td></ +tr></table>"; if(($f{'action'} eq "delete")&&(open(FILE,$f{'file'}))){ unlink($f{'file'})||print "<h1>Could Not Delete: ".$f{'file'}."</h +1>"; } $dir=$f{'dir'} if $f{'password'} eq $password; opendir(DIR,$dir); @dirfiles=readdir(DIR); closedir(DIR); @dirfiles=sort(@dirfiles); print "<p><center><table border=0 cellpadding=5 cellspacing=0><tr><td> +"; print "<p><center><table border=0><tr><form action=".$ENV{'REQUEST_URI +'}." method=post><td>\n"; print "<input type=hidden name=dir value=\"".$location."\" size=40>\n" +; print "<input type=hidden name=password value=orianphoto size=40></td> +\n"; print "<td rowspan=2><input type=submit value=\"Click Here To View Con +tents Of Directory\"></td></tr>\n"; print "<tr><td><input type=hidden name=password value=orianphoto size= +40></td></form></tr></table></center></p>\n\n"; print "</td></tr><tr><td>\n\n\n"; print "<p><center><table border=1><tr>\n"; print "<form action=".$ENV{'REQUEST_URI'}." method=post>\n"; print "<input type=hidden name=action value=delete>\n"; print "<td bgcolor=navy><font color=white><B>Files in The Photo Direct +ory: </td></tr><tr><td>\n"; $i=0; foreach $file(@dirfiles){ if((!opendir(TEST,$dir."/".$file))&&($f{'password'} eq $password)& +&($file ne ".")&&($file ne "..")){ $i++; print "<input type=checkbox name=file value=\"".$dir."/".$file +; if($i==1){ print "\" checked>"; }else{ print "\">"; } print $file."<BR>\n"; } } print "<input type=hidden name=dir value=\"".$location."\">\n"; print "<input type=hidden name=password value=orianphoto>\n"; print "<input type=submit value=\"Delete Selected File\"></td>\n"; print "</form></tr></table></center></p>"; print "</td></tr></table></center></p>\n"; print "$footer";

In reply to Converting To CGI.PM by lisaw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.