CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Text File Content Printing?



Oct 3, 2000, 5:00 AM

Post #1 of 3 (1121 views)
Text File Content Printing? Can't Post

I can't make it so I print the entire content of a text file.

I open the file and get the data,
but simply can't make it print it to the browser.

Print to the file works fine, ut read from file
and print it jut doesn't work Frown



Oct 3, 2000, 10:26 PM

Post #2 of 3 (1121 views)
Re: Text File Content Printing? [In reply to] Can't Post

Thank you.
That helped and worked.


User / Moderator

Oct 4, 2000, 7:52 AM

Post #3 of 3 (1121 views)
Re: Text File Content Printing? [In reply to] Can't Post

Browsers can get really upset if you don't tell them what 'Content-type' to use, or you give them text before the Content-type.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

my $filename = 'textfile.html';
print "Content-type: text/html\n\n";

open (DATA, $filename) or die ("could not open $filename, $!\n");
while (<DATA> ){
print $_;
close DATA;

It you want to print straight text remember to use "Content-type: text/plain\n\n".

Also you can rewrite this without the word 'while', but that is left as an exercise for the reader.

[This message has been edited by rGeoffrey (edited 10-04-2000).]


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives