← Documentation Index

NAME

Test::Mailmunge::Tmpdir - create and (usually) clean up a temporary directory

ABSTRACT

Test::Mailmunge::Tmpdir creates a temporary directory under ./t/tmp and (unless told otherwise) removes it just before the program exits. More specifically, the directory is removed with the Test::Mailmunge::Tmpdir object goes out of scope.

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);

CONSTRUCTOR

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

Returns a new object $tmp_obj. The newly-created temporary directory is in $tmp_obj->{dir} and the "cleanup" flag is in $tmp_obj->{cleanup}.

AUTHOR

Dianne Skoll <dianne@skollsoft.com>

LICENSE

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

Copyright © 2021 Skoll Software Consulting