#!/usr/local/bin/perl # 2010c.pl print "Content-type: text/html\n\n"; # i realize i should probably be using CGI.pm library # rather than using the below code to handle URL encoded # POST- that will be my next step if ($ENV{"REQUEST_METHOD"} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } $studentid = $FORM{'studentid'}; $CSC = $FORM{'CSC'}; chomp($CSC); $assignment = $FORM{'assignment'}; $file = $FORM{'file'}; # here's the code I wrote that I'm having conceptual # problems with if ($CSC eq "CSC2010") { if ($studentid eq "laura") { if ($assignment eq "1") { $HOME = (getpwnam("wfp51916"))[7]; $filename = "$HOME/classes/csc2010/laura/1/outputfile.txt"; open( OUTFILE, ">>$filename" ) or die ( "no go miss "); print OUTFILE "$studentid\n"; close( OUTFILE ); } } }