On Mon Jul 17 16:58:57 2006, NIKC wrote:
Show quoted text> What's the benefit of this module over tempdir() from File::Temp?
Convenience. To use tempdir (which is what the module does), you have
to load the module, create the tempdir, then every time you want to do
something, you have to properly concatenate the filename onto the
directory. Since perl builtins don't throw exceptions, you have to
error check, too. All in all, it's a lot of lines of code to do
something very simple.
I give an example in the RATIONALE section of the POD:
"Before": (11 lines)
use Test::More tests => 42;
use Foo::Bar;
my $TESTDIR = "/tmp/test.$$";
my $FILE = "$TESTDIR/file";
mkdir $TESTDIR;
open(my $file, '>', $FILE);
print {$file} "test\n";
close($file);
ok(-e $FILE);
# tests
END { `rm -rf $TESTDIR` }
After: (7 lines)
use Test::More tests => 42;
use Foo::Bar;
use Directory::Scratch;
my $tmp = Directory::Scratch->new;
my $FILE = $tmp->touch('file');
ok(-e $FILE)
# tests
All of my CPAN modules (and non-CPAN perl software; see
www.jrock.us/trac for those) are file-based, and I needed a fast and
convenient way to make lots of files and directories.
Directory::Scratch has made my test-writing life 100x better :)
I thought that I'm not the only one that does this, hence I released the
module to CPAN.
Regards,
--
Jonathan Rockway <jrockway@cpan.org>