Re: My preferred way of handling config data in Perl is:
by tbone1 (Monsignor) on Dec 14, 2006 at 12:34 UTC
|
.ini files.
Encrypted .ini files.
In Sumerian.
(Although once, because of a typo, I created a .nin file and the code got all depressed, dressed in black, bemoaned having to sell out to the music industry, and moved to the local art district. Who knew?)
--
tbone1, YAPS (Yet Another Perl Schlub)
And remember, if he succeeds, so what.
- Chick McGee
| [reply] |
|
Actually, I think I saw it in Cleveland once :-)
| [reply] |
|
.ini files.
Encrypted .ini files.
In Sumerian. Also known as nam-shubs.
=cut
--Brent Dax
There is no sig.
| [reply] |
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by zshzn (Hermit) on Dec 14, 2006 at 04:00 UTC
|
Whatever happened to .txt and .config files? | [reply] |
|
I usually use .txt files instead of .ini. Alternatively, .rc files are nice as well... On the other hand, if you will be passing your script to someone else, embedding the config data in the script is a little more portable (although forces you to update the code eveytime there is a config change, versus just messing with the .ini/ .txt/ .rc file).
Ah, TIMTOWTDI.
| [reply] |
Re: My preferred way of handling config data in Perl is:
by mce (Curate) on Dec 14, 2006 at 10:06 UTC
|
My All time favorite Config::Simple.
Plain old ini files.
---------------------------
Dr. Mark Ceulemans
Product Manager
Bull, Belgium
| [reply] |
Re: My preferred way of handling config data in Perl is:
by rhesa (Vicar) on Dec 14, 2006 at 00:56 UTC
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by ikegami (Patriarch) on Dec 14, 2006 at 04:09 UTC
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by gloryhack (Deacon) on Dec 14, 2006 at 12:37 UTC
|
I prefer YAML, but the folks who pay me prefer .ini files. The folks who pay me think a closure is what keeps a brassiere from falling off... | [reply] |
Re: My preferred way of handling config data in Perl is:
by Nkuvu (Priest) on Dec 14, 2006 at 17:41 UTC
|
I ask the user. Every single time.
Sure, it's repetitive, and yes, the users get frustrated, but it's so fun to ask them the same questions every time (with confirmation for each question). The best part is when I ask for configuration options that my scripts don't use. ("Enter the distance from the Earth to the sun, in centimeters: ")
Or maybe I just use text files -- but that's a less interesting answer, so...
| [reply] [d/l] |
Re: My preferred way of handling config data in Perl is:
by strat (Canon) on Dec 15, 2006 at 10:05 UTC
|
It depends on what kind of data is in the configuration
I usually use a Module called SomeNamespace::Config.pm which either contains the configuration or provides an interface for it, or uses "Plugins" like SomeNamespace::Config::AccessData.
- For synchronizing data for metadirectories, I often save the configuration of the connected directories in the central data directory and access it through Net::LDAP or DBI and write a little application to change it. And if you want to work with a version control system, you can easily put LDIF- or SQL-files under version control. This is very easy because if you have several systems (e.g. develop, test, integration, preproduction, production), you don't need to edit config files or perl code manually. The only problem is the data you need to access the central data directory: I either put them into a perl module like Namespace::Config::AccessData or the like, or put it into a little INI or YAML file.
- For web or Tk applications I like both YAML or ini files, or if it get's too complicated: even a perl module.
- For little command line scripts, Getopt::Long and friends are often absolutely ok
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
| [reply] |
Re: My preferred way of handling config data in Perl is:
by jonadab (Parson) on Dec 14, 2006 at 11:18 UTC
|
require './config.pl';
After all, sometimes the configuration needs to calculate values or
define objects or subroutines (e.g., a callback). An .ini file just
can't handle those needs. And sometimes defining a set of related
options together, e.g. with map, improves the clarity of the config
file, and .ini can't do that, either.
Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
| [reply] [d/l] |
Re: My preferred way of handling config data in Perl is:
by EvanK (Chaplain) on Dec 14, 2006 at 20:53 UTC
|
For small projects, Config::Simple, and for larger ones, Config::General
__________ Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
- Terry Pratchett
| [reply] |
Re: My preferred way of handling config data in Perl is:
by talexb (Chancellor) on Dec 14, 2006 at 03:25 UTC
|
YAML rocks my world .. but watch out for the indentation .. muck it up and data will mysteriously disappear. Thanks Ingy!
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds
| [reply] |
|
yaml is neat, but the std module seems quite slow reading/writing?
| [reply] |
|
use Best [[ qw/ YAML::Syck YAML / ], [qw/Load Dump/];
print Dump($complex_thingie);
| [reply] [d/l] |
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by eserte (Deacon) on Dec 14, 2006 at 07:33 UTC
|
I started using YAML again, since there is another YAML handling module (YAML::Syck) and INGY restarted YAML.pm development. For emacs users, there is yaml-mode and now it's also possible to use schemas on YAML (or JSON) files: Kwalify | [reply] |
Re: My preferred way of handling config data in Perl is:
by stonecolddevin (Parson) on Dec 16, 2006 at 08:29 UTC
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by philcrow (Priest) on Dec 14, 2006 at 13:54 UTC
|
We use Gantry::Conf more and more. All conf files go in /etc/gantry.d. They are instance tagged, so all an app or script needs to know is the instance name. Pass that to the retrieve method and presto all your conf in a lovely hash. It even handles location specific conf to mimic PerlSetVars from Apache conf. The instances can easily share common conf in several ways. The conf file format is up to you, but we use Config::General's format.
Phil | [reply] |
Re: My preferred way of handling config data in Perl is:
by leocharre (Priest) on Dec 14, 2006 at 06:40 UTC
|
CGI::Ex::Conf is a nice interface to various conf type files. You can use YAML (yeah!), ini, json, etc files.
| [reply] |
Re: My preferred way of handling config data in Perl is:
by Ben Win Lue (Friar) on Dec 14, 2006 at 09:25 UTC
|
something else:
Most time I do my konfiguration in the database, especially complex konfiguration.
If I don't have a database or I have to configure which database to use, I do configuration by ini-files or environment variables.
| [reply] |
|
| [reply] [d/l] |
|
++ just for your .sig.
Jack
| [reply] |
|
In same place you store the information that says how to read from the environment / the command line / a config file / etc. ?
At some point, you have to tell the program where to look, and what to look for, no matter what it is you're looking at...
| [reply] |
|
|
|
Re: My preferred way of handling config data in Perl is:
by Juerd (Abbot) on Dec 15, 2006 at 00:46 UTC
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by Discipulus (Canon) on Dec 15, 2006 at 08:00 UTC
|
ok small config go into my %conf; at the very beginning.
medium config below wonderful __DATA__ token (no one mentioned it. I' m so stupid to do so ?!?).
big configs shared between 2 or more scripts go into a quick 'n dirty exported on request only %conf_one in a conf_Project.pm
ty all
Lorenzo* | [reply] [d/l] [select] |
Re: My preferred way of handling config data in Perl is:
by arc_of_descent (Hermit) on Dec 15, 2006 at 08:25 UTC
|
Text files, with simple one-liners, enclosed in xml tags if there are multiple sections. All thanks to Config::General
| [reply] |
Re: My preferred way of handling config data in Perl is:
by nimdokk (Vicar) on Dec 14, 2006 at 17:00 UTC
|
Sorta like .ini I suppose, but I simply use files named .cfg instead (depending on what it is being used for of course :-) | [reply] |
|
Well, I name them .conf actually :)
| [reply] |
Re: My preferred way of handling config data in Perl is:
by hiseldl (Priest) on Dec 14, 2006 at 21:33 UTC
|
Config::General because I like the variable substitution, the grouping/sub-grouping capability, and it handles Apache-style and ini files as well. Plus, it has a tie interface.
| [reply] [d/l] |
Re: My preferred way of handling config data in Perl is:
by Mutant (Priest) on Dec 14, 2006 at 11:48 UTC
|
"YAML" is catchy and fun to say. Try it. "YAML, YAML, YAML!!!" | [reply] |
Re: My preferred way of handling config data in Perl is:
by gam3 (Curate) on Dec 14, 2006 at 22:42 UTC
|
| [reply] |
Re: My preferred way of handling config data in Perl is:
by SFLEX (Chaplain) on Dec 14, 2006 at 12:26 -04
|
"Something else: please tell"
Ok, its MySQL. | [reply] |
Re: My preferred way of handling config data in Perl is:
by mr_mischief (Monsignor) on Dec 14, 2006 at 16:46 UTC
|
I've been use'ing Perl modules for configuration a bit lately. It's almost like hard-coding, but it's in a different file and I make a hash for each feature group that is kind of self-documenting.
It might not be the most user-friendly, but I tend to use these for things like configuring database names and hostnames, then stick user-level configs behind an options interface within the user interface.
| [reply] |
Re: My preferred way of handling config data in Perl is:
by ides (Deacon) on Dec 21, 2006 at 10:02 UTC
|
Gantry::Conf is all I use these days. However, Config::General is another good choice IMHO.
| [reply] |
Re: My preferred way of handling config data in Perl is:
by parv (Parson) on Dec 17, 2006 at 16:51 UTC
|
Programs that I advertise about (and/or not in public domain) use command line arguments, and sometimes __DATA__, for the configuration. Otherwise, plain old variables & possibly __DATA__ hold the configuration. | [reply] |
Re: My preferred way of handling config data in Perl is:
by alpha (Scribe) on Dec 17, 2006 at 17:01 UTC
|
Data::Dumper + perl code ftw ;) | [reply] |
Re: My preferred way of handling config data in Perl is:
by spatterson (Pilgrim) on Dec 18, 2006 at 12:35 UTC
|
Oh, so many options *grin* Appconfig::File or XML::Simple for persistent configuration. AppConfig::File's easy to edit manually, XML::Simple is handy if you want perl to edit its own config file.
Plus my vars for quick & dirty hacks & command line parameters sometimes as well.
just another cpan module author
| [reply] [d/l] |
Re: My preferred way of handling config data in Perl is:
by pajout (Curate) on Dec 20, 2006 at 09:32 UTC
|
I prefer this way, upper has higher priority:
- command line arguments
- %ENV
- file configuration (it means XML for me)
- hardcoded defaults
Mixing these options gives me desired flexibility.
The other practice, which I use sometimes, is to treat relative paths as relative to real location of the executed file (excluding mod_perl cases). | [reply] |
|
The other practice
No way that I am prepared to discuss my "other practice" on a public forum :-)
Cheers, Rob
| [reply] |
Re: My preferred way of handling config data in Perl is:
by sir_lichtkind (Friar) on Dec 24, 2006 at 07:20 UTC
|
I like Config General, but just as HoH. It sucks while serialisation of Arrays, so in this case i prefer YAML, waiting on YAML::Tiny
| [reply] |
Re: My preferred way of handling config data in Perl is:
by starX (Chaplain) on Dec 18, 2006 at 16:17 UTC
|
other: unix hidden files (.filename) that contain init data. Anything complex I would prefer XML though. | [reply] |
Re: My preferred way of handling config data in Perl is:
by parv (Parson) on Mar 19, 2008 at 02:30 UTC
|
I had mistakenly expected Config::(Simple|Tiny) to support reading from a given file handle based on their name. Config::Ini had the same problem of expecting only a file name, not a file handle. As a result of that, I use Config::General instead.
| [reply] |
Re: My preferred way of handling config data in Perl is:
by temporal (Pilgrim) on Oct 18, 2012 at 10:42 UTC
|
I'm a fan of using AppConfig
Handling CLI and config file options in the same module - quite handy.
| [reply] |
Re: My preferred way of handling config data in Perl is:
by Tux (Canon) on Jan 02, 2007 at 09:27 UTC
|
I was to say "who needs configure stuff, hard-code it all, so people cannot make mistakes", but then I realized that .ini files should of course be .rc files (what's in a name).
Then there are <DATA> (__END__), command-line-arg driven hash keys that make you select a prefefined configuration by key, etc. etc.
| [reply] [d/l] [select] |
Re: My preferred way of handling config data in Perl is:
by lovekumar (Initiate) on Dec 20, 2006 at 04:46 UTC
|
I would make a .pm file let say Config.pm, store my config in form of Data Structure let say $CONFIG and export this var to other modules.
require Exporter;
use vars qw/ @EXPORT/;
@EXPORT = qw/$CONFIG/;
do something with $CONFIG now. | [reply] |
Re: My preferred way of handling config data in Perl is:
by Anonymous Monk on Dec 19, 2006 at 13:12 UTC
|
what better than the registry? | [reply] |
|
| [reply] |