Thanks! That did the trick, I *KNEW* there had to be a better way to do it, I 
just didn't know what it was :-)

On Monday 08 April 2002 01:43 pm, John W. Krahn wrote:
> > sub check() {
> >         my ($dir,@toCheck) = @_;
> >         my $last = @toCheck;
> >         my $i;
> >         my $valid;
> >
> >         # Go to the directory we need to check
> >         print "\nEntering $dir\nChecking for $last files\n";
> >         chdir($dir) or die "Unable to change to $dir: $!\n";
> >         opendir(DIR, $dir) or die "Unable to open $dir: $!\n";
> >
> >         # Loop throught the directory we were passed
> >         while(my $file = readdir(DIR)) {
> >                 # First gid rid of those pesky . and .. things
> >                 if($file eq "." || $file eq "..") {
> >                         next;
> >                 }
> >
> >                 $valid = 0;
> >                 # Now loop through the array of filenames we were passed
> >                 for($i = 0; $i < $last && !$valid; $i++) {
> >                         # Make sure the file exists
> >                         if ($file eq $toCheck[$i]) {
> >                                 print "\t\- $file.....OK\n";
> >                                 $valid = 1;
> >                         }
> >                 }
> >
> >                 ##
> >                 # $i not valid
> >                 #
> >                 if (!$valid) {
> >                         #if($file ne "." || $file ne "..") {
> >                                 # If its FUBAR add it to the array, and
> > let us know print "\t\- $file.....ERROR\n";
> >                                 push(@missingFiles,"$dir/$file");
> >                         #}
> >                 }
> >         }
> >
> >         # Be nice and close our directory handle
> >         closedir DIR;
> > }

> You are doing _waaay_ too much work to see if a file exists.
>
> sub check() {
>     my $dir = shift;
>
>     for my $file ( @_ ) {
>         if ( -e "$dir/$file" ) {
>             print "\t- $file.....OK\n";
>             }
>         else {
>             print "\t- $file.....ERROR\n";
>             push @missingFiles, "$dir/$file";
>             }
>         }
>     }
>
>
>
> John

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to