Test::M...::Tmpdir(3)

πŸ“¦ version 3.20, in alpine 3.24

πŸ’… Test::Mailmunge::Tmpdir β€” from the User Contributed Perl Documentation ✨

okay bestie, so the actual name of this page is Test::M...::Tmpdir(3) (it's been abbreviated, iykyk) but the module we're actually talking about is Test::Mailmunge::Tmpdir, and honestly? it's such a handy little thing.


🌸 NAME 🌸

Test::Mailmunge::Tmpdir β€” creates you a temporary directory and (usually) cleans it up after itself, like a well-behaved roommate 🧹✨

πŸŽ€ ABSTRACT πŸŽ€

So here's the tea: Test::Mailmunge::Tmpdir spins up a temporary directory under "./t/tmp" and β€” unless you tell it otherwise β€” deletes that whole thing right before the program exits. πŸ—‘οΈ

But like, more specifically (because the details matter, bestie): the directory gets removed when the Test::Mailmunge::Tmpdir object goes out of scope. That's the actual trigger. Out of scope β†’ cleanup. Periodt. πŸ‘‘

✨ SYNOPSIS ✨

use Test::Mailmunge::Tmpdir;

my $tmp_obj = Test::Mailmunge::Tmpdir->new();
my $dir = $tmp_obj->{dir};

# Create files, etc in $dir

if (something_went_horribly_wrong()) {
    # Oh no!  Don't clean up the temp dir
    $tmp_obj->{cleanup} = 0;
}

# Directory will be cleaned up prior to exit
# unless we set $tmp_obj->{cleanup} to 0.
exit(0);

like, it's giving "I made a mess but I'll handle it" energy, and then ✨plot twist✨ β€” if something_went_horribly_wrong() you just flip $tmp_obj->{cleanup} to 0 and the directory stays put for your forensic investigation πŸ”πŸ’€

🌈 CONSTRUCTOR 🌈

Test::Mailmunge::Tmpdir->new()

Gives you back a fresh new object called $tmp_obj 🫢 The brand-new temporary directory lives in "$tmp_obj->{dir}", and the "cleanup" flag lives in "$tmp_obj->{cleanup}". That's it, that's the whole vibe check β€” no cap.

πŸ’– quick reminder: $tmp_obj->{dir} = your directory, $tmp_obj->{cleanup} = whether it gets yeeted on scope exit. Don't lose track of either, bestie.

πŸ‘‘ AUTHOR πŸ‘‘

Dianne Skoll <dianne@skollsoft.com> β€” literal icon, we stan πŸ’œ

πŸ’… LICENSE πŸ’…

This code is licensed under the terms of the GNU General Public License, version 2. fr fr, respect the license.


and that's the whole page, bestie πŸ¦‹ β€” source & version check: perl v5.42.2, dated 2025-10-05, brought to you by Test::M...::Tmpdir(3) ✨ mwah πŸ’‹

πŸ“¦ where this page comes from