replacemore.cgi
#!/usr/bin/perl if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); if ($ENV{'QUERY_STRING'}) { @getpairs =split(/&/, $ENV{'QUERY_STRING'}); push(@pairs,@getpairs); } } else { print "Content-type: text/html\n\n"; print "<P>Use Post or Get"; } @classes = ("Latin 305", "Advanced Greek Grammar", "Applied Linguistics", "Virgil and the Iliad"); @newclasses = split(/,/, $formdata{'newclass'}); @IDs = split(/,/, $formdata{'ID'}); print "Content-type: text/html\n\n"; print "<P><B>You replaced: </B>"; foreach $number (@IDs) { $number--; print "<LI>$classes[$number]"; } print "<P><B>with:</B> "; foreach $course (@newclasses) { if ($course ne " ") { print "<LI>$course"; @newarray = (@newarray, $course); } } @classes[@IDs] = @newarray; print "<h2>Your complete list is now:</h2><UL>"; foreach $item (@classes) { print "<LI>$item"; } print "</UL>";