You've got the basic idea on how to open up a file and print out its contents to the client. I don't understand how HTTP:: or LWP:: modules would help you with this. I see that you named the file handle HEAD, so does this mean that the file only contains the HTTP headers to be sent out??

Anyhow, you can do the following to print out the entire contents of a file to the client:

#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; open HEAD, 'file.txt' or die "Could not open file.txt: $!"; print while <HEAD>; close HEAD;

Hrmm... 5.006 does support warnings, strict, $! for error, and file handles, right? {grin}


BTW, I meant to mention: if you're looking for a box to work on, read up jcwren's home node for information on getting an account on the box he so generously provides for members of perlmonks. I'm not sure he'd appreciate an actual business being run from it, but if all you need is a personal account to test with, I'm sure he'd be happy to supply you with one :)


If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.


In reply to Re: Different ways of including files in a CGI Script by Coruscate
in thread Different ways of including files in a CGI Script by shirkdog_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.