Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-03-2009, 12:28 AM   #1
LQ Newbie
Registered: Mar 2009
Distribution: Slamd64
Posts: 26

Rep: Reputation: 15
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:

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:


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?

Last edited by JoeBleaux; 04-03-2009 at 12:46 AM. Reason: Fixed the Param problem
Old 04-03-2009, 02:00 AM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Shouldn't the content-type header refer to 'text/html'?
--- rod.
Old 04-03-2009, 05:54 AM   #3
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,551

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

Last edited by j-ray; 04-03-2009 at 05:55 AM.
Old 04-03-2009, 08:54 AM   #4
LQ Newbie
Registered: Mar 2009
Distribution: Slamd64
Posts: 26

Original Poster
Rep: Reputation: 15
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!


cgi, html, perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read HTML or TXT file and output the data? koolkicks311 Programming 1 04-21-2007 12:13 AM
[Perl] - save input in .html file noir911 Programming 2 01-07-2007 03:36 PM
PERL: Can you open an HTML file from a web address? SparceMatrix Programming 3 02-07-2006 12:06 PM
How can i read an write to a HTML or xml file using C alix123 Programming 1 11-24-2004 06:07 AM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 06:07 AM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration