.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Config::Find 3pm" .TH Config::Find 3pm "2021-01-06" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Config::Find \- Find configuration files in the native OS fashion .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Config::Find; \& \& my $filename=Config::Find\->find; \& \& ... \& \& my $fn_foo=Config::Find\->find( name => \*(Aqmy_app/foo\*(Aq, \& mode => \*(Aqwrite\*(Aq, \& scope => \*(Aquser\*(Aq ); \& \& my $fn_bar=Config::Find\->find( names => [qw(my_app/bar appbar)] ); \& \& my $fh=Config::Find\->open( name => \*(Aqfoo\*(Aq, \& scope => \*(Aqglobal\*(Aq, \& mode => \*(Aqw\*(Aq ) \& \& \& my $fn=Config::Find\->install( \*(Aqoriginal/config/file.conf\*(Aq, \& name => \*(Aqfoo\*(Aq ); \& \& my $fn=Config::Find\->find( file => $opt_c, \& name => foo ); .Ve .SH "ABSTRACT" .IX Header "ABSTRACT" Config::Find searches for configuration files using \s-1OS\s0 dependent heuristics. .SH "DESCRIPTION" .IX Header "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. .PP 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 \f(CW\*(C`emacs\*(C'\fR, \f(CW\*(C`profile\*(C'\fR, \&\f(CW\*(C`apache/httpd\*(C'\fR, \f(CW\*(C`apache/ssl\*(C'\fR. .PP By default the \f(CW$0\fR value is used to generate the configuration file name. To define it explicitly the keywords \f(CW\*(C`name\*(C'\fR or \f(CW\*(C`names\*(C'\fR have to be used: .ie n .IP "name => ""name"" or ""app/file""" 4 .el .IP "name => \f(CWname\fR or \f(CWapp/file\fR" 4 .IX Item "name => name or app/file" picks the first configuration file matching that name. .IP "names => [qw(foo bar foo/bar)]" 4 .IX Item "names => [qw(foo bar foo/bar)]" picks the first configuration file matching any of the names passed. .PP Alternatively, the exact position for the file can be specified with the \f(CW\*(C`file\*(C'\fR keyword: .ie n .IP "file => ""/config/file/name.conf""" 4 .el .IP "file => \f(CW/config/file/name.conf\fR" 4 .IX Item "file => /config/file/name.conf" explicit position of the configuration file. .Sp If undef is passed this entry is ignored and the search for the configuration file continues with the appropriate \s-1OS\s0 rules. This allows for: .Sp .Vb 2 \& use Config::Find; \& use Getopt::Std; \& \& our $opt_c; \& getopts(\*(Aqc:\*(Aq); \& \& my $fn=Config::Find\->find(file => $opt_c) .Ve .PP Methods in this package also accept the optional arguments \f(CW\*(C`scope\*(C'\fR and \f(CW\*(C`mode\*(C'\fR: .ie n .IP "scope => ""user"" or ""global""" 4 .el .IP "scope => \f(CWuser\fR or \f(CWglobal\fR" 4 .IX Item "scope => user or global" Configuration files can be private to the application user or global to the \s-1OS,\s0 i.e. in unix there is the global \f(CW\*(C`/etc/profile\*(C'\fR and the user \f(CW\*(C`~/.profile\*(C'\fR. .ie n .IP "mode => ""read"" or ""write""" 4 .el .IP "mode => \f(CWread\fR or \f(CWwrite\fR" 4 .IX Item "mode => read or write" In \f(CW\*(C`read\*(C'\fR mode already existent file names are returned, in \f(CW\*(C`write\*(C'\fR mode the file names point to where the configuration file has to be stored. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" All the methods in this package are class methods (you don't need an object to call them). .ie n .IP "$fn=Config::Find\->find(%opts)" 4 .el .IP "\f(CW$fn\fR=Config::Find\->find(%opts)" 4 .IX Item "$fn=Config::Find->find(%opts)" returns the name of the configuration file. .ie n .IP "$fh=Config::Find\->open(%opts)" 4 .el .IP "\f(CW$fh\fR=Config::Find\->open(%opts)" 4 .IX Item "$fh=Config::Find->open(%opts)" returns a open file handle for the configuration file. In write mode, the file and any nonexistent parent directories are created. .ie n .IP "$fn=Config::Find\->install($original, %opts)" 4 .el .IP "\f(CW$fn\fR=Config::Find\->install($original, \f(CW%opts\fR)" 4 .IX Item "$fn=Config::Find->install($original, %opts)" copies a configuration file to a convenient place. .SH "BUGS" .IX Header "BUGS" Some Win32 operating systems are not completely implemented and default to inferior modes, but hey, this is a work in progress!!! .PP Contributions, bug reports, feedback and any kind of comments are welcome. .SH "SEE ALSO" .IX Header "SEE ALSO" Config::Find::Unix, Config::Find::Win32 for descriptions of the heuristics used to find the configuration files. .PP Config::Find::Any for information about adding support for a new \&\s-1OS.\s0 .PP Config::Auto give me the idea for this module. .SH "AUTHOR" .IX Header "AUTHOR" Salvador Fandiño García, .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" Barbie, (some bug fixes and documentation) .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2003\-2015 by Salvador Fandiño García (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.