#!/usr/local/bin/perl sub readPostData { local(*queryString) = @_ if @_; local($contentLength); # Read the environment variable CONTENT_LENGTH $contentLength = $ENV{"CONTENT_LENGTH"}; # Make sure that there is data to read if($contentLength) { # Read contentLength characters from STDIN into queryString read(STDIN,$queryString,$contentLength); } # Return 1 for success return 1; } # Read the envorinmental variable REQUEST_METHOD, this should be post $requestType = $ENV{"REQUEST_METHOD"}; # Print the header required for all CGI scripts that output dynamic text data print "Content-type: text/plain\n\n"; # Make sure that this is a post request if($requestType eq "POST") { # Call our function to read the data from stdin # Notice that we use the variable name, not its value as an arguement &readPostData(*data); # Print the data that we read print "The POST data is:\n\n"; print $data; print "\n"; }