PM_WHICH(1)

πŸ’… PM_WHICH πŸ’…

okay so bestie, listen β€” pm_which is literally the tool that finds your installed modules for you. no cap, it's giving "where did I put my keys" but for Perl. you're gonna love her.


✨ SYNOPSIS ✨

pm_which [ options ] module(s)

Returns the path to the given module(s) β€” like a little treasure map but for .pm files πŸ—ΊοΈπŸ’–

πŸŽ€ OPTIONS πŸŽ€

  • -q, --quiet β€” Just print paths. no small talk, no extra vibes.
  • -p, --paths β€” Just convert the module name into a relative path.
  • -a, --all β€” Print all paths, not just the first one found. when you need receipts πŸ”
  • -n, --namespace β€” Print all modules in the given namespace.
  • -m β€” Only print module names, not paths. literally just the names, bestie.
  • -V β€” Show module version. because sometimes you gotta know.
  • -I libpath β€” Add a path to search (like perl -I). your custom stash πŸ’…
  • -d, --dump β€” Dump paths that would be searched (@INC by default).
  • -h, --help β€” Print this message. we love a helpful icon.
  • -v, --version β€” Print version information.
  • - β€” Read modules from stdin, one per line. feed her lines like a queen πŸ“

🌸 DESCRIPTION 🌸

okay so this tool reports the locations of installed perl modules. that's it. that's the vibe.

by default it lists the location of each specified module that would be loaded by require. simple. elegant. iconic.


πŸ¦‹ OPTION DETAILS πŸ¦‹

🌈 quiet

under quiet mode, module names are suppressed and missing modules are not reported. it's giving "no small talk hours."

normal output:

$ pm_which Module::One Module::Two Missing::Module
Module::One     - /path/to/Module/One.pm
Module::Two     - /path/to/Module/Two.pm
Missing::Module - not found

under --quiet:

$ pm_which -q Module::One Module::Two Missing::Module
/path/to/Module/One.pm
/path/to/Module/Two.pm

see how the missing one just... doesn't show up? she's not gonna embarrass herself by reporting a ghost. πŸ’€

🌟 paths

in "paths" mode, each module is simply converted into a relative file path. this is possible even when the module is not installed. so you can manifest it into existence, kinda? ✨

$ pm_which -p Missing::Module
Missing/Module.pm

πŸ’« all

when the "all" switch is specified, all installed modules will be reported, not just the first one. this is useful for determining when there is a module installed in multiple locations. like when you have the same hoodie in three colors β€” except it's .pm files and slightly less cute 🫢

$ pm_which -a MyModule
/path/to/MyModule.pm
/home/me/perl/MyModule.pm

🧚 namespace

arguments are taken as namespaces to search under. it's giving "show me the whole family tree" 🌳

$ pm_which -n MyModule
MyModule            - /path/to/MyModule.pm
MyModule::Foo       - /path/to/MyModule/Foo.pm
MyModule::Foo::Bar  - /path/to/MyModule/Foo/Bar.pm

πŸ’œ -m

disables printing of module paths. this is only really useful in conjunction with --namespace. like, it's not the main character on its own, but paired with -n? lowkey iconic.

$ pm_which -nm MyModule
MyModule
MyModule::Foo
MyModule::Foo::Bar

πŸ”₯ -V

prints the version of each module, according to ExtUtils::MakeMaker. because sometimes you need to know exactly what version you're dealing with. it's giving "check the tag before you commit" 🏷️

$ pm_which -V MyModule
MyModule - /path/to/MyModule.pm [ 1.00 ]

$ pm_which -Vnm MyModule
MyModule [ 1.00 ]
MyModule::Foo [ 0.01 ]
MyModule::Foo::Bar [ undef ]

not the [ undef ] for the last one 😭 she tried her best.

⭐ dump

dumps the paths that would be searched and exits. this is @INC modified by any -I switches. think of it as "what's in the search bag before we go looking" πŸŽ’

$ pm_which --dump
/usr/lib/perl5/site_perl/5.8.6
/usr/lib/perl5/vendor_perl/5.8.6
...

$ pm_which -I lib --dump -I blib/lib
lib
blib/lib
/usr/lib/perl5/site_perl/5.8.6
...

πŸŽ€ version

prints the version number of the script, plus the version and path of Module::Util that was loaded. the whole "about me" page but for a script πŸ’…


πŸ‘‘ EXIT CODES πŸ‘‘

  • 0 β€” Everything was OK. slay.
  • 1 β€” Initialisation failed (bad switches?). it happens to the best of us 😭
  • 2 β€” Some modules were not installed. they ghosted you, fr.

🌈 SEE ALSO 🌈

this utility comes with Module::Util. so like, they're besties. they come together. dynamic duo energy 🫢


πŸ’– AUTHOR πŸ’–

Matt Lawrence <mattlaw@cpan.org>


that's the whole thing, bestie! go forth and find those modules. you got this πŸ’…βœ¨

this slay of a script was last updated on 2023-01-20 and runs on perl v5.32.1. iconic behavior all around πŸŽ€

πŸ“¦ where this page comes from