tevus_oriley has asked for the wisdom of the Perl Monks concerning the following question:
I need to verify that a bunch of files exist and are not empty. The basic location is '/strek/$race/logs/rlog0-4.sr.html'
This is what I have so far, which is failing: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); } while (my $race = <@races>) { for my $i (0..4) { if ( -s '/strek/$race/logs/rlog$i.sr.html' ) { next; } else { print "/strek/$race/logs/rlog$i.sr.html either does not exist + or is 0 bytes!\n"; } } }
This is executing the print statement every time, including for files that should be 'true'. Can anyone help with this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: file check loop
by toolic (Bishop) on Jul 30, 2013 at 15:13 UTC | |
|
Re: file check loop
by Anonymous Monk on Jul 30, 2013 at 15:22 UTC | |
by hippo (Archbishop) on Jul 30, 2013 at 17:44 UTC | |
|
Re: file check loop
by marinersk (Priest) on Jul 30, 2013 at 17:06 UTC | |
|
Re: file check loop
by mtmcc (Hermit) on Jul 30, 2013 at 15:24 UTC | |
by 2teez (Vicar) on Jul 30, 2013 at 17:36 UTC | |
by AnomalousMonk (Archbishop) on Jul 30, 2013 at 15:48 UTC | |
|
Re: file check loop
by Cristoforo (Curate) on Jul 30, 2013 at 16:59 UTC | |
|
Re: file check loop
by Laurent_R (Canon) on Jul 30, 2013 at 21:32 UTC |