.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Config::Find 3pm" .TH Config::Find 3pm "2015-08-02" "perl v5.20.2" "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 Fandin\*~o Garci\*'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 Fandin\*~o Garci\*'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.