Next | Program Repair Shop | 45 |
The function's job is to create a directory
Let's just tell it what directory we want it to create
sub CreateOutputDir { my $dir = shift; print "Creating DIR: ",$dir,"\n"; $I = mkdir($dir,0777); if ($I) { print "Success! \n"; } else { print "Fail! : $! \n"; } }
Then the calls to it become:
&CreateOutputDir("$InputDir1/$NextOut"); &CreateOutputDir("$InputDir2/$NextOut");
Or, replacing the variable family with an array:
for my $dir (@InputDir) { &CreateOutputDir("$dir/$NextOut"); }
Greater modularity, greater flexibility
Same amount of code
Next | Copyright © 2002 M. J. Dominus |