SYNOPSIS

  use Config::Find;

  my $filename=Config::Find->find;

  ...

  my $fn_foo=Config::Find->find( name => 'my_app/foo',
                                 mode => 'write',
                                 scope => 'user' );

  my $fn_bar=Config::Find->find( names => [qw(my_app/bar appbar)] );

  my $fh=Config::Find->open( name => 'foo',
                             scope => 'global',
                             mode => 'w' )


  my $fn=Config::Find->install( 'original/config/file.conf',
                                name => 'foo' );

  my $fn=Config::Find->find( file => $opt_c,
                             name => foo );

ABSTRACT

Config::Find searches for configuration files using \s-1OS\s0 dependent heuristics.

DESCRIPTION

Every \s-1OS\s0 has different rules for configuration files placement, this module allows one to easily find and create your app configuration files following those rules.

Config::Find references configuration files by the application name or by the application name and the configuration file name when the app uses several application files, i.e \*(C`emacs\*(C', \*(C`profile\*(C', \*(C`apache/httpd\*(C', \*(C`apache/ssl\*(C'.

By default the $0 value is used to generate the configuration file name. To define it explicitly the keywords \*(C`name\*(C' or \*(C`names\*(C' have to be used: picks the first configuration file matching that name.

names => [qw(foo bar foo/bar)]

picks the first configuration file matching any of the names passed.

Alternatively, the exact position for the file can be specified with the \*(C`file\*(C' keyword: explicit position of the configuration file. If undef is passed this entry is ignored and the search for the configuration file continues with the apropiate \s-1OS\s0 rules. This allows for: use Config::Find; use Getopt::Std;

our $opt_c; getopts('c:');

my $fn=Config::Find->find(file => $opt_c)

Methods in this package also accept the optional arguments \*(C`scope\*(C' and \*(C`mode\*(C': Configuration files can be private to the application user or global to the \s-1OS\s0, i.e. in unix there is the global \*(C`/etc/profile\*(C' and the user \*(C`~/.profile\*(C'. In \*(C`read\*(C' mode already existant file names are returned, in \*(C`write\*(C' mode the file names point to where the configuration file has to be stored.

\s-1METHODS\s0

All the methods in this package are class methods (you don't need an object to call them). returns the name of the configuration file. returns a open file handle for the configuration file. In write mode, the file and any nonexistant parent directories are created. copies a configuration file to a convenient place.

\s-1EXPORT\s0

None, this module has an \s-1OO\s0 interface.

BUGS

Some Win32 OSs are not completely implemented and default to inferior modes, but hey, this is a work in progress!!!

Contributions, bug reports, feedback and any kind of comments are welcome.

RELATED TO Config::Find…

Config::Find::Unix, Config::Find::Win32 for descriptions of the heuristics used to find the configuration files.

Config::Find::Any for information about adding support for a new \s-1OS\s0.

Config::Auto give me the idea for this module.

COPYRIGHT AND LICENSE

Copyright 2003-2008 by Salvador Fandin\*~o Garci\*'a ([email protected])

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.