Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Different ways of including files in a CGI Script

by Coruscate (Sexton)
on Feb 17, 2003 at 01:42 UTC ( [id://235847]=note: print w/replies, xml ) Need Help??


in reply to Different ways of including files in a CGI Script

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.

Replies are listed 'Best First'.
Re: Re: Different ways of including files in a CGI Script
by shirkdog_perl (Beadle) on Feb 17, 2003 at 01:52 UTC
    Well I mentioned the modules to give an overview of the situation. Actually the HEAD file is just HTML past the first body tag. CGI.pm takes care of the header. I also have $! in place for error handling. Also I have already set up a site with jcwren. But as you noted about running a business from the server, I am looking to do more. What is funny is JCWREN's server offers more for free :-). I have thought about ways of uploading ths source code of modules to my hosting site and using the modules that way (also an idea from a fellow monk). I will be looking into that this week.

      Rosehosting have pushed some advertising Perlmonks way so deserve a plug. I have had a VS with them for 6 months and have been very impressed with the bandwidth and uptime. You can get a virtual server with full SSH root access so you can install/do more or less whatever you want for $29US a month. The bandwith they have is excellent and the average server load rarely exceeds 5% average. They take about a day to set up your server. You get a pretty functional version of Redhat 7.3, sendmail, Apache 1.3.23 http and https mod_perl (but you really need to upgrade that to 1.3.27 for security) + perl 5.6.1 They advertise MYSQL and postgres (these were not installed) but build easily from source.

      They have gone the M$ way and have a lot of services running by default that you will want to kill of but besides that it is a pretty fair deal.

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://235847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found