October 27, 2005 Two or Three Things I Learned ...

File::Temp

Use File::Temp when testing requires creation of directories or files.

{

    use_ok( 'File::Temp', qw| tempdir |);
    my $tdir = tempdir( CLEANUP => 1);
    ok(chdir $tdir, 'changed to temp directory for testing');
    ...
    ok(chdir $cwd, 'changed back to original directory');

}


Home Last TOC Copyright © 2005 James E Keenan Prev Next