in reply to Unit test - check file created using test::directory
This is how i would do that:
use strict; use warnings; use File::Temp qw( tempdir ); use Test::More tests => 2; my $fname = 'foo.txt'; my $dir = tempdir( CLEANUP => 1 ); is -f "$dir/$fname", undef, "file does not exit"; create_file( $dir, $fname ); is -f "$dir/$fname", 1, "file now exists"; sub create_file { my ($path, $fname) = @_; open FH, '>', "$path/$fname" or die "$!\n"; close FH; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Unit test - check file created using test::directory
by APGRMF (Novice) on Jul 04, 2014 at 15:57 UTC | |
Re^2: Unit test - check file created using test::directory
by GotToBTru (Prior) on Jul 03, 2014 at 18:27 UTC | |
by jeffa (Bishop) on Jul 03, 2014 at 19:39 UTC |