Config::Find(3pm)

πŸ“¦
version 0.31 Β· 2 versions
  • 0.31 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.31 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Config::Find πŸ’– β€” the Config::Find(3pm) page, bestie edition

okay so this is Config::Find, a Perl module, and it's here to help you find configuration files the way your actual operating system wants them found. No cap.


✨ NAME ✨

Config::Find</purgle> β€” find configuration files in the native OS fashion πŸ¦‹


🌸 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 πŸŽ€

Literally what it says on the tin: Config::Find searches for configuration files using OS dependent heuristics. πŸ’…


🌈 DESCRIPTION 🌈

Every OS has its own whole thing about where config files should live, and honestly? iconic of them. This module lets you easily find and create your app's configuration files while following those rules, so you don't have to hardcode paths like a Victorian orphan. 🫢

Config::Find references configuration files by the application name, or by the application name plus the configuration file name when your app is a whole multi-file situation β€” think "emacs", "profile", "apache/httpd", "apache/ssl". πŸ¦‹

By default the $0 value is used to generate the configuration file name. If you wanna define it explicitly, you use the keywords "name" or "names":

  • name => "name" or name => "app/file" β€” picks the first configuration file matching that name. main character energy, first match wins ✨
  • names => [qw(foo bar foo/bar)] β€” picks the first configuration file matching any of the names you passed in. a lil lineup, take your pick πŸ’…

Alternatively, you can just say exactly where the file is with the "file" keyword:

  • file => "/config/file/name.conf" β€” explicit position of the configuration file. no heuristics, no detective work, just the exact spot πŸ“

If undef is passed, this entry is ignored and the search for the configuration file continues with the appropriate OS rules. Which is lowkey the whole point, because it lets you do this:

  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 "scope" and "mode":

  • scope => "user" or scope => "global" β€” configuration files can be private to the application user, or global to the OS. like, in unix there's the global /etc/profile and the user ~/.profile. both valid, both serving 🫢
  • mode => "read" or mode => "write" β€” in "read" mode you get back file names that already exist; in "write" mode the file names point to where the configuration file has to be stored. read = vibe check what's there, write = make it happen ✨

🧚 METHODS 🧚

All the methods in this package are class methods (you don't need an object to call them, bestie, just call them straight on the class). πŸ’œ

  • $fn=Config::Find->find(%opts) β€” returns the name of the configuration file. πŸ”
  • $fh=Config::Find->open(%opts) β€” returns an open file handle for the configuration file. In write mode, the file and any nonexistent parent directories are created. it's giving "I'll build the whole path for you" πŸ˜­πŸ’–
  • $fn=Config::Find->install($original, %opts) β€” copies a configuration file to a convenient place. πŸŽ€

πŸ’€ BUGS πŸ’€

Some Win32 operating systems are not completely implemented and default to inferior modes β€” but hey, this is a work in progress!!! πŸ™ˆ we're aware, we're working on it

Contributions, bug reports, feedback and any kind of comments are welcome. fr fr, slide into the repo 🫢


πŸ”₯ SEE ALSO πŸ”₯

  • Config::Find::Unix, Config::Find::Win32 β€” for descriptions of the heuristics used to find the configuration files. iykyk πŸ“š
  • Config::Find::Any β€” for information about adding support for a new OS. go off, expand the lore 🌍
  • Config::Auto β€” give me the idea for this module. shoutout to the muse ✨

πŸ‘‘ AUTHOR πŸ‘‘

Salvador FandiΓ±o GarcΓ­a, <sfandino@yahoo.com>

🌟 CONTRIBUTORS 🌟

Barbie, <barbie@missbarbell.co.uk> (some bug fixes and documentation) πŸ’…


Copyright 2003-2015 by Salvador FandiΓ±o GarcΓ­a (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk)

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


and that's the whole page, bestie πŸŽ€ this was perl v5.36.0, dated 2022-12-07 β€” thanks for reading the Config::Find(3pm) manual with me, you ate that πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from