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

In reply to Re: Global includes in cgi's by andreychek
in thread Global includes in cgi's by L8on

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.