Elijah has asked for the wisdom of the Perl Monks concerning the following question:
Now this script works fine but when this script sends the target script source code to the web browser the cgi source code in the script gets parsed as html code. Is there anyway I can use this method and not have the web browser parse the cgi source code as html code and simply display as text?#!/usr/bin/perl -w use strict; use CGI qw(param); my $cgi = new CGI; my @param = $cgi->param(); my $path = "/home/master/webroot/newdesign/scripts/"; my @source; error() unless @param; my $full = $path.$param[0]; if (-e $full) { open(FILE, "$full") || error(); @source = <FILE>; close(FILE); print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<last; <html> <head><title>$param[0]</title> </head> <body bgcolor="#000000" text="#808080" leftmargin="0" marginwidth="0" +topmargin="0" marginheight="0"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> last for (@source) { print; print "<br>\n"; } print <<last2; </td> </tr> </table> </body> </html> last2 }else{ error(); } sub error { print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<end; <html> <head><title>Error!</title> </head> <body bgcolor="#000000" text="#808080" leftmargin="0" marginwidth="0" +topmargin="0" marginheight="0"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> There was an error while trying to post script source! </td> </tr> </table> </body> </html> end exit(0); }
Also along the same lines all the scripts source code formatting (spaces, indentation, basically all whitespace) gets stripped from the source code and all source code is aligned with the left margin. This is not as big of a deal but I would like the scripts to keep their formatting after being sent to the browser.
You can see this script in action and actually see the indications I am talking about above in action at the production server link that follows: http://4.46.66.37/master/webroot/newdesign/scripts.htm
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: issues displaying cgi script source?
by diotalevi (Canon) on Jul 06, 2004 at 20:49 UTC | |
by Elijah (Hermit) on Jul 06, 2004 at 21:37 UTC | |
by diotalevi (Canon) on Jul 06, 2004 at 22:14 UTC | |
|
Re: issues displaying cgi script source?
by diotalevi (Canon) on Jul 06, 2004 at 22:27 UTC | |
by Elijah (Hermit) on Jul 06, 2004 at 22:32 UTC | |
by diotalevi (Canon) on Jul 06, 2004 at 22:35 UTC | |
by Elijah (Hermit) on Jul 06, 2004 at 22:41 UTC | |
by antirice (Priest) on Jul 07, 2004 at 01:10 UTC | |
| |
|
Re: issues displaying cgi script source?
by Joost (Canon) on Jul 06, 2004 at 20:37 UTC | |
|
Re: issues displaying cgi script source?
by jZed (Prior) on Jul 06, 2004 at 20:30 UTC | |
by Elijah (Hermit) on Jul 06, 2004 at 20:43 UTC | |
by Joost (Canon) on Jul 06, 2004 at 20:47 UTC | |
by antirice (Priest) on Jul 07, 2004 at 00:52 UTC | |
|
•Re: issues displaying cgi script source?
by merlyn (Sage) on Jul 06, 2004 at 23:03 UTC | |
| |
|
Re: issues displaying cgi script source?
by sgifford (Prior) on Jul 07, 2004 at 04:50 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |