App::F...::Trace(3pm)

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

πŸ’– App::FatPacker::Trace β€” the manual page, bestie edition πŸ’–

okay so. this is App::FatPacker::Trace, a Perl module from the User Contributed Perl Documentation crew, section 3pm. she's a little tracing icon and she's about to tell you exactly which modules your code is out here loading. no cap. πŸ•΅οΈβ€β™€οΈβœ¨


🌸 NAME 🌸

App::FatPacker::Trace β€” tracing module usage using compilation checking πŸ’…


✨ SYNOPSIS ✨

# open STDERR for writing
# will be like: open my $fh, '>', '&STDERR'...
perl -MApp::FatPacker::Trace=>&STDERR myscript.pl

# open a file for writing
# will be like: open my $fh, '>>', 'fatpacker.trace'
perl -MApp::FatPacker::Trace=>>fatpacker.trace myscript.pl

like. that's the whole vibe. one line and she's already spilling everything your script touches. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

This module lets you trace the modules being used by your code. and the way she does it? clever trickery, bestie. she's using the "import" method, the "CHECK" block, and B's "minus_c" function. it's giving hacker girl main character energy and honestly? obsessed. πŸ’€

So when App::FatPacker::Trace is being used, the import() method will call "B::minus_c" to set up the global compilation-only flag perl (the interpreter, not the language, keep up 🫢) has. What does that flag do? It prevents any other code from being run. periodt. nothing runs past that point.

Then, in the "CHECK" block β€” which gets reached at the end of the compilation phase (peep perlmod if you wanna know more πŸ“š) β€” she gathers up all modules that have been loaded, using %INC, and writes them out to a file or to STDERR. which one? determined by the parameters sent to the "import" method. you're in control, queen. πŸ‘‘


πŸŽ€ METHODS πŸŽ€

πŸ’œ import

This method gets run when you just load App::FatPacker::Trace. Here's what she does in order, no skipping:

  • she notes the current %INC πŸ“
  • she sets up the output to be written to
  • she raises the compilation-only flag, which prevents anything from being run past that point

and here's the thing: this flag cannot be unset. cannot. it's forever. πŸ’€ so the most easily way to run this is straight from the command line, like:

perl -MApp::FatPacker::Trace [...]

You can control the parameters to the import using an equal sign, like this:

# send the parameter "hello"
perl -MApp::FatPacker::Trace=hello [...]

# send the parameter ">&STDERR"
perl -MApp::FatPacker::Trace=>&STDERR [...]

The import method accepts a first parameter telling it which output to open and how. Both of those things β€” the output and the how β€” get sent in a single parameter. one param, two jobs. multitasking icon. ✨

# append to mytrace.txt
perl -MApp::FatPacker::Trace=>>mytrace.txt myscript.pl

# write to STDERR
perl -MApp::FatPacker::Trace=>&STDERR myscript.pl

The import method also accepts additional parameters of extra modules to load. She'll then add these modules to the trace. 🫢

Why would you want that? Because sometimes you need to explicitly indicate additional modules to trace, even if they aren't actually used in your script. Maybe you're conditionally using them, maybe they're for additional features, maybe they're loaded lazily β€” whatever the reason, bestie, she's got you. no judgement. 🌈

# Add Moo to the trace, even if you don't trace it in myscript.pl
perl -MApp::FatPacker::Trace=>&STDERR,Moo myscript.pl

🌟 little reminder: that compilation-only flag from up top? she cannot be unset. so plan your one-liner before you fire it off, okay? πŸ’…

and that's the whole page, angel. 🧚 this beauty ships with perl v5.36.0 and was dated 2022-11-20 β€” go forth and trace your little heart out. mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from