Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Global includes in cgi's

by andreychek (Parson)
on Jun 09, 2001 at 22:46 UTC ( #87218=note: print w/ replies, xml ) Need Help??


in reply to Global includes in cgi's

The mod_perl guide has an excellent tutorial on writting configuration files.

Although it's referring to mod_perl, I don't see any reason why it wouldn't also work under ordinary CGI.

In short, the mod_perl guide offers this code:

# Configuration File Example package My::Config; use strict; use vars qw(%c); %c = ( dir => { cgi => "/home/httpd/perl", docs => "/home/httpd/docs", img => "/home/httpd/docs/images", }, url => { cgi => "/perl", docs => "/", img => "/images", }, color => { hint => "#777777", warn => "#990066", normal => "#000000", }, ); # Main CGI application example use strict; use My::Config (); print "Content-type: text/plain\r\n\r\n"; print "My url docs root: $My::Config::c{url}{docs}\n";
Again, that code is verbatim out of the mod_perl guide, and I included a link to it above. While you could directly use this code, I highly recommend reading the entire section in the guide regarding configuration files so you can decide if this is the best method for you or not. It contains a lot of good information, and is very well written.

If you don't like the idea of using actual Perl code in your config file, there are modules at CPAN that allow you to write config files in other formats. Check out Config::IniFiles, XML::Simple, and Config::General.

Good luck!
-Eric


Comment on Re: Global includes in cgi's
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-07-24 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (159 votes), past polls