NAME

File::ConfigDir - Get directories of configuration files

SYNOPSIS

use File::ConfigDir ':ALL';

my @cfgdirs = config_dirs();
my @appcfgdirs = config_dirs('app');

# install support
my $site_cfg_dir = site_cfg_dir();
my $vendor_cfg_dir = site_cfg_dir();

DESCRIPTION

This module is a helper for installing, reading and finding configuration file locations. It's intended to work in every supported Perl5 environment and will always try to Do The Right Thing(tm).

File::ConfigDir is a module to help out when perl modules (especially applications) need to store and read configuration files from more than one location. Writing user configuration is easy thanks to File::HomeDir, but what when the system administrator needs to place some global configuration or there will be system related configuration (in /etc on UNIX(tm) or $ENV{windir} on Windows(tm)) and some network configuration in nfs mapped /etc/p5-app or $ENV{ALLUSERSPROFILE} . "\\Application Data\\p5-app", respectively.

EXPORT

Every function listed below can be exported, either by name or using the tag :ALL.

SUBROUTINES/METHODS

All functions can take one optional argument as application specific configuration directory. If given, it will be embedded at the right (tm) place of the resulting path.

system_cfg_dir

Returns the configuration directory where configuration files of the operating system resides. For Unices this is /etc, for MSWin32 it's the value of the environment variable %windir%.

machine_cfg_dir

Returns the configuration directory where configuration files of the operating system resides. For Unices this is /etc, for MSWin32 it's the value of the environment variable %ALLUSERSPROFILE% concatenated with the basename of the environment variable %APPDATA%.

core_cfg_dir

Returns the etc directory below $Config{prefix}.

site_cfg_dir

Returns the etc directory below $Config{sitelib_stem} or the common base directory of $Config{sitelib} and $Config{sitebin}.

vendor_cfg_dir

Returns the etc directory below $Config{vendorlib_stem} or the common base directory of $Config{vendorlib} and $Config{vendorbin}.

local_cfg_dir

Extracts the INSTALL_BASE from $ENV{PERL_MM_OPT} and returns the etc directory below it.

here_cfg_dir

Returns the path for the etc directory below the current directory.

user_cfg_dir

Returns the users home folder using File::HomeDir. Without File::HomeDir, nothing is returned.

config_dirs

@cfgdirs = config_dirs();
@cfgdirs = config_dirs( 'appname' );

Tries to get all available configuration directories as described above. Returns those who exists and are readable.

AUTHOR

Jens Rehsack, <rehsack at cpan.org>

BUGS

Please report any bugs or feature requests to bug-file-configdir at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-ConfigDir. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc File::ConfigDir

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2010 Jens Rehsack.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.