My anonymous brother is quite right. You can avoid this sort of problem (where by you test one thing but actually report another) by using a variable name for both. eg.
my $file = "/strek/$race/logs/rlog$i.sr.html";
if ( -s $file ) {
next;
} else {
print "$file either does not exist or is 0 bytes!\n";
}
Other things you could do include making more use of the $ldir variable and rolling the second loop into the first.
#!/usr/bin/perl
use strict;
use warnings;
my $ldir = '/strek';
my @races = undef;
opendir my $dh, $ldir
or die "$0: opendir: $!";
while (defined(my $name = readdir $dh)) {
next unless -d "$ldir/$name";
push (@races, $name);
for my $i (0..4) {
my $file = "$ldir/$name/logs/rlog$i.sr.html";
if ( -s $file ) {
next;
} else {
print "$file either does not exist or is 0 bytes!\n";
}
}
}
# Now do something useful with @races here
|