Document(3pm)

πŸ’– NAME πŸ’–

App::perlimports::Document β€” bestie, we're making implicit imports explicit ✨ like, out loud, on the page, no more hiding 🫢


πŸŽ€ VERSION πŸŽ€

version 0.000060 β€” yes it's slaying, keep up πŸ’…


🧠 MOTIVATION 🧠

okay so listen πŸ™ˆ this module is strictly for internal use by perlimports. It's the backstage crew, the stagehands, the little guys behind the curtain. Nothing else should be relying on it, fr fr β€” so don't you dare build your whole app on top of it, that's not the vibe πŸ‘‘.

πŸ” inspector_for( $module_name )

Hands you back an App::perlimports::ExporterInspector object for whatever module name you pass in. That's it, that's the whole thing πŸ’–

βœ… linter_success

Returns true if the document got linted with zero errors, otherwise false. A little vibe check for your file 🌈 β€” true means we're thriving, false means we're not πŸ₯²

πŸͺ„ tidied_document

Returns a serialized PPI document with (hopefully πŸ‘€) tidy import statements. Emphasis on hopefully, bestie β€” we do our best.


🌸 ATTRIBUTES 🌸

πŸ“š constants

A hashref catalog of every detected constant in the document. So like, the line:

use constant FIRST_IDX => 0;

gives you a matching entry in the constants hashref:

FIRST_IDX => {
  name        => 'FIRST_IDX', # (plain string)
  token       => 'FIRST_IDX', # (PPI::Token::Word usually)
  definition  => [ PPI::Token.. ],
  end         => { line => 9, column => 32 },
},

The end is the (line, character) position of the last character of the constant import statement. Why do you care? Because the constant is only actually defined at compile time, and only after this statement β€” so the position is genuinely useful info fr 🧚

⚠️ heads up bestie: locations can become stale! Don't trust them forever, okay? πŸ’€

The name field is the hero when the constant got defined with atypical syntax (no fat arrow), because the token doesn't stringify the same way. Watch:

use constant 'FIRST_IDX', 0;
# token eq "'FIRST_IDX'", # (PPI::Token::Quote::Single)
# name  eq 'FIRST_IDX',   # same as $token->string

See?? The token is out here with quotes and the name is just clean 🫧 iconic behaviour honestly.

πŸ“¦ includes

An arrayref of PPI::Statement::Include statements found in the document β€” but excluding pragmas, ignored modules, and 'use VERSION' statements. They're not invited to this party πŸ™…β™€οΈ

πŸ—‚οΈ found_imports

A hashref catalog of symbols imported from each package by a use statement, like:

{ Carp => ['croak', ..], ... }

Now here's the tea β˜•, and it depends on your mode:

  • In lint mode, this attribute is never altered. Hands off, it's chillin' 🌴
  • In edit mode, when tidied_document gets called, every include that gets processed updates this list to what we think it should be ✨

Why do we bother? So we can keep track of what the previous modules are really importing, which lets us avoid duplicate imports β€” you know, the same symbol name coming in from different packages πŸ˜΅β€πŸ’« Nobody wants that mess.


πŸ‘‘ AUTHOR πŸ‘‘

Olaf Alders <olaf@wundercounter.com> β€” king behaviour, we stan 🫢


This software is copyright (c) 2020 by Olaf Alders.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So like, go forth and remix bestie πŸ’…


aaaand that's the whole page!! brought to you by perl v5.40.1, dated 2026-05-11, filed under Document(3pm) β€” mwah, go read some source code, ily πŸŒˆπŸ’–βœ¨

πŸ“¦ where this page comes from