in reply to Configuration file design

if the user is perlwise (and only then), my favourite option is to simply put the config-data as perl code in the config-file, like
"root" => "/path/to/root", "filepath" => "/path/to/files", "ftp_instances" => [ { "sourcepath" => "/source/path/on/server", "savepath" => "/save/files/here", }, { "sourcepath" => "/source/path/on/server", "savepath" => "/save/files/here", }, ]
Then you can simply read the file, do
eval "%CFG = (" . readfile("cfg") . ");";
and you´re gone.

The benefit is that you can safely bring in all kind of difficult data (newlines etc.), and you can use an idiom you are pretty much used to.

just my $ 2/100

Replies are listed 'Best First'.
Re^2: Configuration file design
by Juerd (Abbot) on Jan 04, 2005 at 16:23 UTC

    eval "%CFG = (" . readfile("cfg") . ");";

    Is there any specific reason for not using my %CFG = do 'cfg'; instead?

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      if any, then because i didn´t know it could be done that way ,-)