[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Printing Scripts to Browser



>From owner-macperl-webcgi@cfcl.com  Tue Jun  8 08:29:07 1999 [slight delay]
Received: from [209.214.78.77] (host-209-214-78-83.atl.bellsouth.net
[209.214.78.83])
	by mail1.atl.bellsouth.net (8.8.8-spamdog/8.8.5) with ESMTP id LAA27572
	for <macperl-webcgi@macperl.org>; Tue, 8 Jun 1999 11:20:26 -0400 (EDT)
Message-Id: <v04205105b382e4e8705d@[209.214.78.77]>
Date: Tue, 8 Jun 1999 11:19:32 -0400
 To: MacPerl Web/CGI List <macperl-webcgi@macperl.org>
 From: Richard Gordon <maccgi@bellsouth>

I am working on the documentation for a large cgi project and decided
that it would be in the spirit of things to do this in html. One of
the features is being able to link references to scripts to a
printing script that I wrote so that the code can be displayed in the
browser window using <PRE></PRE> tags to provide simple formatting.
This works okay, but gets real weird if the script in question
includes html tags that are being written as the script actually
executes.

In other words, a cgi script may include setting some bold tags,
etc., and when I print the script to the browser, the browser
interprets these literally and applies them. That's annoying enough,
but since the closing tags are escaped in order to be used in the
script (e.g., <\/B> instead of </B>) things get mangled and I wind up
with output in bold or italics or whatever. In fact, I even get
tables produced within the script or images dragged into it, so this
is very odd to look at.

Anyway, does anyone know how to render html tags inert when they are
printed from a script to the browser? I've pasted in what I am using
at the moment and am looking for something that would tell the
browser to ignore the tags, yet still present them as ordinary text
in the window. Thanks.

#!/usr/bin/perl -w

$query_string = $ENV{QUERY_STRING};
$path = "/cgi-bin/SBL/";
$file = $path.$query_string;
$/ = undef;
print ("Content-type: text/html\n\n");

open(F, "<$file") or die ("Can't Open $!");
$lines = <F>;
$lines =~ s|\\/|/|gsm;
close <F>;
print ("<HTML><BODY><PRE>\n");
print $lines;
print ("<\/PRE><\/BODY><\/HTML>\n");

Richard Gordon
--------------------
Gordon Consulting & Design
Database Design/Scripting Languages
mailto://richard@richardgordon.net
770.565.8267

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org