Plack:...Cleanup(3pm)

πŸ’– Plack::Session::Cleanup β€” aka Plack:...Cleanup(3pm) πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation set, and it's literally the tiniest lil bop. It's called Plack::Session::Cleanup and it does exactly one job, but it does it flawlessly. πŸ’…


✨ NAME ✨

Plack::Session::Cleanup β€” run code when the environment is destroyed. that's it. that's the whole vibe. 🫢


🌸 SYNOPSIS 🌸

$env->{'run_at_cleanup'} = Plack::Session::Cleanup->new(
    sub {
        # ...
    }
);

look at her. so clean. so demure. 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

so the tea is: this module gives Plack::Middleware::Session a little runway to run code the moment the environment gets cleaned up. That's the whole serve. πŸŽ€


πŸ‘‘ METHODS πŸ‘‘

🌟 new ( $coderef )

When you build one of these bad boys, it holds onto your $coderef and fires it off when the object gets "DESTROY"'d. Like, the moment it's destroyed, boom, your code runs. iconic behaviour, no cap. πŸ’«

⚠️ bestie please read this part: you gotta be careful that the code reference you hand over does not close over $env. Because if it does, you create a cycle, and then $env can never, ever be destroyed. it's giving trapped-forever energy and not in a cute way. 😭 the whole point is the cleanup, and a cycle means no cleanup. so watch that closure. fr fr. πŸ’€

πŸ’œ sign-off πŸ’œ

and that's the page, babe! this lil doc ships with perl v5.40.1, dated 2025-08-10, and it's filed under Plack:...Cleanup(3pm). go forth and destroy your environments responsibly. mwah. πŸ’–πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from