Config...::Where(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

πŸ’– NAME πŸ’–

Config::Find::Where β€” bestie, it finds you locations the way your OS actually wants them found. native OS fashion, no cap. ✨


πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the vibe, literally copy-paste:

use Config::Find::Where;

my $temp_dir=Config::Find::Where->temp_dir( name => 'my_app',
                                            scope => 'process',
                                            create => 1 );

my $path=Config::Find::Where->bin_dir( scope => 'app' );
system $path."/app_helper.exe";

that's it. that's the whole thing. πŸ’…


πŸ¦‹ ABSTRACT πŸ¦‹

Config::Find goes looking for locations using OS dependent heuristics. periodt.


🌸 DESCRIPTION 🌸

so after releasing Config::Find I was like… wait. a LOT of that code could be reused to find other interesting things too?? like temporary directories, the script location, etc etc. πŸ’­

and this module is that β€” it adds a public API to all the hidden functionality. the glow-up fr fr. πŸ‘‘

✨ OPTIONS ✨

same as in Config::Find, every single method in this package accepts one common set of options:

  • name => "name" or "name/more/names" β€” says the primary application name, the one used to generate the location paths or to go search for them. 🏷️
  • scope => "user", "global", "app" or "process" β€” -
  • create => 1 β€” creates any nonexistent directory in the path returned. makes it exist. slay. πŸͺ„

πŸ’œ METHODS πŸ’œ

all the methods in this package are class methods β€” you don't need an object to call them, just call them on the class. easy.

  • $path=Config::Find::Where->temp_dir(%opts) β€” returns a directory path inside a system temporary location. i.e.:
Config::Find::Where->temp_dir( name =>'hello/world',
                               scope => 'process',
                               create => 1 )

returns something similar to

'/tmp/jacks/hello/974/world/'

on unix like systems and

'C:\Windows\Temp\jacks\hello\974\world'

on some Windows ones. and yes bestie, 'jacks' is supposed to be the current user name and '974' is the process number. 😌

The default scope for this method is "user".

  • $path=Config::Find::Where->bin_dir(%opts) β€” returns a place to find/place binary files. The default scope for this method is "app".

i.e.

Config::Find::Where->bin_dir()

returns the path to the directory where binaries are located.

🚨 note that this directory is not necessarily the same as the one containing the running script. See documentation for "script_dir" below. don't get caught out, okay??
  • $path=Config::Find::Where->var_dir(%opts) β€” returns a place to find/place working files.

The default scope for this method is "app".

  • $path = Config::Find::Where->lib_dir(%opts) β€” returns a place to find/place library files.

The default scope for this method is "app".

For instance:

use lib => Config::Find::Where->lib_dir;
  • $path = Config::Find::Where->application_dir(%opts) β€” returns the application root directory. the whole main character of directories. πŸ‘‘
  • $name=Config::Find::Where->script_name() β€” returns the name of the running script without any path information. just the name. no baggage. πŸ’«
  • $path=Config::Find::Where->script_full_path() β€” returns the name of the script as the absolute full path to it.
  • $path=Config::Find::Where->script_dir() β€” returns the name of the directory containing the current script.
  • Config::Find::Where->create_dir($dir) β€” creates directory $dir and any needed parents. brings the whole family along. 🫢
  • Config::Find::Where->create_parent_dir($file) β€” recursively creates all the nonexistent parent directories for $file. recursively!! it goes all the way up. 😭
  • Config::Find::Where->helper_path($file, %opts) β€” searches for a script, based on the directories given in %opts, which are the same as bin_dir() method.

πŸ’€ BUGS πŸ’€

some Win32 operating systems are not completely implemented and default to inferior modes, but hey, this is a work in progress!!! πŸ™ˆ

Contributions, bug reports, feedback and any kind of comments are welcome. like genuinely, come through. πŸ’Œ


🌈 SEE ALSO 🌈

Config::Find


πŸ‘‘ 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 β€” perl v5.36.0, dated 2022-12-07, and you're reading Config...::Where(3pm). go find your directories. you ate. βœ¨πŸ’–πŸ¦‹

πŸ“¦ where this page comes from