in reply to Shell to Perl conversion

You're not limited to Perl with CGI, a shell script can be used as a CGI script as well. See http://httpd.apache.org/docs/1.3/howto/cgi.html

In your case, print to STDOUT instead of the $OUT file and print the HTTP header before your output

echo "Content-type: text/plain" echo