#!/acclib/perl5/bin/perl my $path = $ENV{'PATH_INFO'}; my $file = 'coord.dat'; # Name the file print "Content-type: text/html\n\n"; #if no path print the frameset if( $path !~ /\S/ ) { print_frameset(); } #if script called with "/entry" appended then print the #left frame and parse the posted data elsif( $path =~ /entry/ ) { parse_form(); print_entry(); } #if script called with "/coord" appended then print the #right frame elsif( $path =~ /coord/ ) { print_coord(); } exit; sub parse_form { $buffer = 0; read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); # needed to convert from HTML receive 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; } #print data to file only if both fields were populated if( $FORM{'source'} =~ /\S/ && $FORM{'dest'} =~ /\S/ ) { open(FILE, ">>$file" ) || die; # Open the file for writing (append) print FILE "$FORM{source} - $FORM{dest}\n"; close FILE; } } sub print_frameset { print "\n
\n"; print "Script written by Neil Gaffin\n"; print " \n"; } sub print_coord { print "\n
\n"; print "\n";
print "Source Space: Row,Col
\n";
print "Dest Space: Row,Col
\n";
print "Example: A8, H1, C5, G3
\n";
print "(Row must be A-H, Col must be 1-8
\n"; print "
\n"; print "
\n \n"; }