12 Oct 2014 14:03:21 UTC
- Distribution: File-Corresponding
- Module version: 0.004
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (12 / 760 / 0)
- KwaliteeBus factor: 1
- 95.69% Coverage
- License: perl_5
- Activity24 month
- Download (16.92KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionJOHANL Johan Lindström
File::Corresponding::Config::Find -- Locate config files (e.g. per user)
use File::Corresponding::Config::Find; my $my_config = ".myapp"; #Find .myapp in any of the user's home directories my $myapp_config_in_home = File::Corresponding::Config::Find->new()->user_config($my_config) or die; #Find .myapp in the current working directory, or in the user's home directory use Path::Class qw/ dir /; my $myapp_config_in_cwd_or_home = File::Corresponding::Config::Find->new(preferred_dirs => [ dir(".") ])->user_config($my_config) or die;
Locate named config files in the usual places, e.g. the current dir, the user's home directory (cross platform).
First the preferred_dirs are searched, then the user's document directory, data directory, and home directory.
I searched for something like this, couldn't find anything.
So I wrote this module, and named it Config::Find. Which is a name already taken by a CPAN module.
But now it's written, and it works, so it stays.
Find an existing readable file called $config_file_name (e.g. ".myapp") in a) $preferred_dirs, or b) the usual user directories ($HOME etc).
Return the complete file name to the config file, or undef if none was found.
Module Install Instructions
To install File::Corresponding, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install File::Corresponding
For more information on module installation, please visit the detailed CPAN module installation guide.