| Next | Program
Repair Shop ![]() |
90 |
34 if (-d $src_file) {
35 if (! -d $dst_file && -e $dst_file ) {
36 die "Can't mkdir $dst_file because a same name file exist\n";
37 } elsif ( ! -e $dst_file ) {
38 print "mkdir $dst_file\n";
39 mkdir $dst_file or die "Couldn't create dir : $dst_file\n";
40 }
You should now have a nagging feeling
Doesn't this sound familiar?
23 if (! -d $target_directory && -e $target_directory) {
24 die "Can't continue because a file has target's dir name\n";
25 } elsif ( ! -e $target_directory ) {
26 mkdir $target_directory || die "Couldn't create dir : $target_node\n";
27 }
Hmmm
Now is a good time to build a test case if we didn't have one yet
Let's get rid of 35-40 and see if anything breaks
Nope, works perfectly
This means that the -d branch now looks like:
if (-d $src_file) {
xcopy($src_file, $dst_file);
}
5 lines become 0
| Next | ![]() |
Copyright © 2002 M. J. Dominus |