#! /usr/bin/perl # # process paging-multilevel-translate form results # redirect stderr to /dev/null and make output unbuffered # open(STDERR, ">/dev/null") or &fail("Can't redirect STDERR: $!"); $| = 1; # Get the input # read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs # @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; $value =~ s/\s+//g; $data{$name} = lc($value); } # send results to the checker # open( PROC,"| /os/prog/paging-multilevel-translate/post.sh") || &fail("post.sh: $!"); keys %data; # reset while( my($k,$v) = each %data) { print PROC "U $k $v\n"; } close( PROC); exit; # HTML # sub html_header { $title = $_[0]; print "Content-type: text/html\n\n\n
\n\n"; } sub html_trailer { print "\n\n"; } # failed to open a required file # sub fail { &html_header("Open Failure"); print "Failed to open $_[0]\n"; &html_trailer; exit; }