Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

What are all the means of application configuration?

by princepawn (Parson)
on Oct 02, 2000 at 21:45 UTC ( [id://34934]=perlquestion: print w/replies, xml ) Need Help??

princepawn has asked for the wisdom of the Perl Monks concerning the following question:

Since there have been very few New Nodes today, I thought I would give everyone something to -- on. Heheh.

Most of you are familiar with Andy Wardley's App::Config module. If not, let me explain. This module reads a series of key = value pairs from a text file, with the ability to store these key/value pairs in appropriate keyed hashes. E.g.,

[db] username = Python password = sucks [backup] machine = guido frequency = 4 hours [logging] file = /var/log/applog level = 2
This would create a nested hash, with backup, logging and db as first-level keys, accessible from your program as:
$app->{logging}->{file}
Or, you can make use of easy nested navigation (a functionality oft-reapeated in other modules --- (Data::DRef, Boulder, cpan:Template) and separate the elements of the path with dots.

Anyway, what I am realizing is that there is a least one other way of initializing an application, and that is via its command-line arguments (Getopt::Long, Getopt:Std, Getopt::Mixed).

So I began to wonder, how many ways can (and should) a Perl application allow itself to be configured? Let's not forget we could also have per-user configuration which portends the use of databases keyed on username (like the Almighty Technological Innovation of One-click Ordering at Amazon.com --- lol).

So give your input. -- to your heart's content. Share your experience. Do something exciting on this Monday morning we all wanted to be over 6 hours ago.

Over and out, the Monk You Love to Hate princepawn. heheh

Replies are listed 'Best First'.
RE: What are all the means of application configuration?
by Zarathustra (Beadle) on Oct 03, 2000 at 00:20 UTC

    Lets not forget about XML.

    XML::Simple makes for an excellent app config also.

    app.rc: <app> <db> <username>Python</username> <password>sucks</password> </db> <backup> <machine>guido</machine> <frequency>4 hours</frequency> </backup> <logging> <file>/var/log/applog</file> <level>2</level> </logging> </app>

    Derives the same access:

    $app->{'db'}->{'username'}
    As well as all the good stuff that comes with xml, such as for checking the "config" file ( actually just another xml doc ), for well-formedness and validity. Also, XML will provide ties for easy config-file update and modification via the application itself, should you choose to use something like XML::Writer. A fun and nice way of getting fancy for say, a web editable/creatable configuration file.
Re: What are all the means of application configuration?
by wardk (Deacon) on Oct 02, 2000 at 21:58 UTC

    Not a real "exciting" answer but since it is monday, and yes it should have ended a good six hours ago, I'll bite :-)

    On a recent project, I used the following:

    • Determine environment - determine hostname (dev/prod) and directory structure (on dev box, we have dev/test)
    • Application settings - stored in RDBMS
    • User settings (for theming, etc) - Cookies

    5 hours, 58 minutes to go...

      I noticed something in wardk's post and it triggered an association. You can use environmental variables to configure an application also!!!!! Mind-bending.

      At least we on the east coast only have 2 hours and 30 minutes to go. HAHAHAHAHAHA!!!

Re: What are all the means of application configuration?
by ncw (Friar) on Oct 02, 2000 at 22:47 UTC
    Some modules (like CPAN) store their config in a specialised Module (like CPAN::Config).

    This is a technique I've used too!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-23 06:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found