Level(3)

πŸ’… Level(3) β€” Perl::Destruct::Level πŸŽ€

ok so this is the manual page for Perl::Destruct::Level, bestie, and it's genuinely so niche but like... kind of iconic? it lets you mess with perl's internal destruction level, which sounds lowkey terrifying and honestly it kind of is, but we move πŸ’–


✨ SYNOPSIS ✨

like, here's the whole vibe:

use Perl::Destruct::Level level => 1;

my $current_destruct_level = Perl::Destruct::Level::get_destruct_level();

that's it. that's the whole thing. so clean 🌸


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so basically this module lets you change perl's internal destruction level. no cap.

the default value of the destruct level is 0, and what that means is that perl literally won't bother destroying all its internal data structures β€” it just lets the OS do the cleanup at exit instead. main character energy honestly, letting someone else handle the mess πŸ’…

now, for perls that were built with debugging support (-DDEBUGGING), there's an environment variable called PERL_DESTRUCT_LEVEL that lets you control the destruction level. this module? it lets you modify it on non-debugging perls too. slay. very "we don't need the fancy build to have options" of it ✨

the relevant values that perl actually recognizes are 1 and 2. that's it. and if you wanna know exactly what they mean, you gotta go consult your source code yourself β€” this page is not gonna hold your hand on that one, sorry bestie πŸ™ˆ

also heads up: some embedded environments might extend the meaning of the destruction level for their own purposes. mod_perl does that, for example. so like... know your environment, iykyk.

⚠️ CAVEATS ⚠️

okay this is the part where we get real πŸ’€

  • this module won't work when it's used from within an END block. like, at all. don't even try it.
  • loading the threads module will set the destruction level to 2. (this is so that spawned threads can properly cleanup their objects, which is fair tbh.)
  • loading modules that load threads β€” even if they never actually spawn a single thread β€” will also set the destruction level to 2. a common example of such a module is Test::Builder. so like... watch out for that one 🫢

πŸ‘‘ AUTHOR πŸ‘‘

copyright Β© 2007 Rafael Garcia-Suarez. this program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. iconic of him, honestly πŸŽ€


🌈 SEE ALSO 🌈

  • perlrun
  • perlhack

go read those if you want the full lore, bestie πŸ“š


and that's the page!! it's from perl v5.40.0, dated 2023-01-20, and it lives at Level(3) in the User Contributed Perl Documentation section β€” mwah, thanks for reading, love u, bye πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from