Test::M...::Tmpdir(3)
π 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
- alpine 3.24: mailmunge-doc 3.20-r0 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms