Perl::...ontext(3pm)

✨ NAME ✨

Perl::PrereqScanner::NotQuiteLite::Context β€” it's a 3pm (User Contributed Perl Documentation) page, bestie, and it's the little context object that holds all the receipts while your scanner works its way through a file. πŸ’–


🌸 DESCRIPTION 🌸

Okay so picture it: this thing is typically used to keep callbacks, an eval state, and the found prerequisites for a processing file. That's the whole job. It's the group chat where everything gets logged. πŸ“βœ¨


πŸŽ€ METHODS πŸŽ€

πŸ’… add

$c->add($module);
$c->add($module => $minimum_version);

This adds a module β€” with or without a minimum version β€” as either a requirement or a suggestion, and which one it lands as depends entirely on the eval state, no cap. You can add the same module with different versions as many times as you wish, queen, it does not care. The actual minimum version for the module gets calculated on the inside (by CPAN::Meta::Requirements). It's giving teamwork. 🫢

🧚 register_keyword_parser, remove_keyword_parser, register_method_parser, register_sub_parser

$c->register_keyword_parser(
  'func_name',
  [$parser_class, 'parser_for_the_func', $used_module],
);
$c->remove_keyword_parser('func_name');

$c->register_method_parser(
  'method_name',
  [$parser_class, 'parser_for_the_method', $used_module],
);

So here's the scenario: you find a module that can export a loader function and it's actually used β€” think Moose, which can export an extends function that will load a module internally. In that case you might also want to register the loader function as a custom keyword dynamically, so the scanner can also run a callback for that function and parse its argument tokens. Dynamic. Iconic. ✨

You can also remove the keyword when you find the module's been noed (and when the module supports unimport). Bye bestie. πŸ‘‹

You can also register a method callback on the fly β€” but you can't remove it. That one's forever. πŸ’€

If you always want to check some functions/methods whenever you load a plugin, just register them using a register method in the plugin. Easy. Done. Slay. 🌈

⭐ requires

Returns a CPAN::Meta::Requirements object for requirements. That's it, that's the whole text. 🧾

πŸŒ™ suggests

Returns a CPAN::Meta::Requirements object for suggestions (these are the requirements that live inside evals) β€” or undef when it's not expected to parse tokens in eval. Knowing the difference is the whole vibe check here. πŸ¦‹


πŸ‘‘ METHODS MOSTLY FOR INTERNAL USE πŸ‘‘

πŸ’œ new

Creates an instance. You usually don't need to call this, bestie, because it's automatically created in the scanner. It just shows up. Main character energy. 🌟

πŸ”₯ has_callbacks, has_callback_for, run_callback_for

next unless $c->has_callbacks('use');
next unless $c->has_callbacks_for('use', 'base');
$c->run_callbacks_for('use', 'base', $tokens);

Let's break it down:

  • has_callbacks returns true if a callback for use, no, keyword, or method is registered.
  • has_callbacks_for returns true if a callback for the module/keyword/method is registered.
  • run_callbacks_for is the one that actually runs the callback. Get it, do it. πŸ’«

πŸ“ has_added

Returns true if a module has already been added as a requirement or a suggestion. Only useful for the ::UniversalVersion plugin β€” like, it's a very specific tool for a very specific situation, iykyk. πŸ™ˆ


πŸ’– AUTHOR πŸ’–

Kenichi Ishigaki, <ishigaki@cpan.org> β€” the author, the legend, the moment. πŸ‘‘


This software is copyright (c) 2015 by Kenichi Ishigaki.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free as in freedom, periodt. πŸ•ŠοΈ


And that's a wrap on this Perl::...ontext(3pm) page from perl v5.40.1, dated 2026-04-21. Go forth and scan those prereqs, bestie πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from