LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Perl: Read a html file and output it... (http://www.linuxquestions.org/questions/programming-9/perl-read-a-html-file-and-output-it-716495/)

JoeBleaux 04-03-2009 12:28 AM

Perl: Read a html file and output it...
 
I'm trying to write a perl script that (at the heart of it) will read an html file one character at a time and send it out via apache.

Meaning a url of:

Code:

http://www.mydomain.com/cgi-bin/read.pl?page=test.html
would read test.html (one character at a time) and send it to Apache to be displayed as a normal web page...

So far I have:

Code:

#!/usr/bin/perl

use CGI qw(:param);

my $page = param('page');

print "Content-type: text/plain; charset=iso-8859-1\n\n";
open FILE, "$page" or die $!;

while($ch = getc(FILE)) {
        print $ch;
        }
 close (FILE);


The page is spit out the web server but, it is displayed EXACTLY (as text) and not as html (meaning the HTML code is visible).

It's late, I'm tired, any ideas?

theNbomr 04-03-2009 02:00 AM

Shouldn't the content-type header refer to 'text/html'?
--- rod.

j-ray 04-03-2009 05:54 AM

...corected... got you wrong. It's the content-type as theNomr said already

JoeBleaux 04-03-2009 08:54 AM

DOH!!!! Like I said, it was late and I was tired.

I don't care what those BSD guys say about you Linux guys, you're okay by me!


All times are GMT -5. The time now is 06:46 AM.