Module::Used(3pm)

πŸ“¦
version 1.3.0 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Module::Used πŸ’–

okay bestie, so this is Module::Used β€” a little gem from the User Contributed Perl Documentation corner of the universe, and it does exactly one iconic thing: it finds the modules your Perl code loads without ever running it. no cap. static analysis but make it cute. πŸ¦‹


✨ NAME ✨

Module::Used β€” find modules loaded by Perl code without running it. (yes, we're psychic. we're not executing anything. we're just reading. πŸ’…)


🌸 VERSION 🌸

this doc is describing Module::Used version 1.3.0. periodt.


πŸŽ€ SYNOPSIS πŸŽ€

use Module::Used qw< :all >;

@modules = modules_used_in_files(@files);
@modules = modules_used_in_modules(@module_names);

# "strict", "Find::Bin", "warnings"
@modules = modules_used_in_string(
    'use strict; require Find::Bin; no warnings;'
);

# "Exporter"
@modules = modules_used_in_string( 'use parent 0.221 qw< Exporter >;' );

like… look at her. she's just vibing and returning arrays. πŸ”₯


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea β˜•: modules get found statically, based on use and require statements. no running, no eval, no drama.

if it spots base or parent being used, you get both that module and the referenced ones back. and if it finds Moose or Moose::Role, it's gonna go hunting for the extends and with sugar too. however β€” and this is the important bit, bestie β€” presently, this will miss modules listed in parentheses. 😭 it's not perfect, she's trying her best.

and listen:

Dynamically loaded modules will not be found. nope. not happening. if you're loading stuff at runtime, this module literally cannot see it. don't come for her. πŸ’€

πŸ‘‘ INTERFACE πŸ‘‘

nothing is exported by default, bestie. nothing. you want the goods? you import everything with the :all tag. that's the whole vibe check.

  • modules_used_in_files( @files ) β€” returns a list of the modules used in the files you named. if there's a problem reading a file, it dies. πŸ’€
  • modules_used_in_modules( @module_names ) β€” returns a list of modules used in the modules you named. if any of those modules weren't found in @INC, it dies. same energy.
  • modules_used_in_string( $string ) β€” returns a list of modules used in the code sitting inside the parameter. yes, just a string. hand her a string, she hands you answers. ✨
  • modules_used_in_document( $document ) β€” returns a list of modules used in the specified PPI::Document. fancy.

🩺 DIAGNOSTICS 🩺

the "something went wrong" corner. read these, they're not just decorative:

  • Could not find module "%s" in @INC. β€” can't find where the named module lives. and heads up: this module will not find any dynamically loaded modules. just so we're clear. 🫢
  • "%s" does not exist. β€” can't find the file. it's giving missing.
  • "%s" is not readable. β€” the file is there but you can't read it. tragic.
  • "%s" is a directory. β€” plot twist: the "file" was actually a directory. πŸ™ˆ
  • Could not parse "%s". β€” PPI could not interpret the file as a Perl document. she looked at it and said "that's not Perl, bestie." 😭

🌈 CONFIGURATION AND ENVIRONMENT 🌈

None, currently. that's it. that's the whole section. clean, minimal, unbothered. πŸ’…


🧚 DEPENDENCIES 🧚

  • Const::Fast
  • Module::Path
  • PPI::Document version

πŸ’€ INCOMPATIBILITIES πŸ’€

None reported. slay.


⭐ BUGS AND LIMITATIONS ⭐

None reported.

please report any bugs or feature requests to bug-module-used@rt.cpan.org, or through the web interface at <http://rt.cpan.org>. (that's the original URL, keeping it exactly as-is, no edits, we don't do that here. πŸ’–)


🌸 SEE ALSO 🌸

  • Devel::Loaded
  • Module::Extract::Namespaces
  • Module::ScanDeps
  • Module::PrintUsed

all her sisters, all iconic in their own right. go say hi. πŸ‘‘


🫢 AUTHOR 🫢

Elliot Shank <perl@galumph.com> β€” thank you for your service. πŸŽ€


Copyright X2008-2012, Elliot Shank "<perl@galumph.com>".

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. see perlartistic. periodt. ✨


πŸ”₯ DISCLAIMER OF WARRANTY πŸ”₯

okay bestie, this part is in ALL CAPS for a reason, so I'm keeping every single word of it, no cap, no skipping:

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

like yes it's scary but it's also legally required so we read it and we move on. πŸ’œ


and that's the whole page, bestie!! this one ships with perl v5.34.0 and is dated 2022-06-15 β€” a little timestamp from the past that we're still obsessed with. πŸ’–βœ¨ bye mwah 🫢

πŸ“¦ where this page comes from